title: NodeJS DNS error: ENOTFOUND
body: <p>I get the follwing error: <code>getaddrinfo ENOTFOUND</code>. The URL I am trying to connect to is a subdomain on HTTPS.</p>
  
  <pre><code>var options = 
      {
          family: 4,
          hostname: 'test.printapi.nl',
          port: 443,
          path: '/v1/oauth',
          method: 'POST',
          requestCert: true,
          headers: {
              host: 'https://test.printapi.nl',
              //'User-Agent': USER_AGENT,
              'Content-Type': 'application/x-www-form-urlencoded',
              'Content-Length': Buffer.byteLength(data)
          }
      };
      options.agent = http.Agent(options);
  
      var req = http.request(options, (res) =&gt; {
        console.log('statusCode: ', res.statusCode);
        console.log('headers: ', res.headers);
  
        res.on('data', (d) =&gt; {
          process.stdout.write(d);
        });
      }, data);
      console.log(data)
      req.write(data)
      req.end();
  
      req.on('error',function(e){
     console.log("Error: "  + e.message); 
     console.log( e.stack );
  });
  </code></pre>
  
  <p>I have tried many things, with the path, hostname etc. When I use fiddler I need to set a proxy, and fiddler will resolve the hostname of test.printapi.nl, and it will authenticate. But when node needs to do it, it does not find the right DNS record. </p>
  
  <p>I have tried <code>dns.getServers()</code>, and it did return the correct DNS server. I also tried the google DNS servers, and that did not help. Am I overlooking something I need to set for the hostname to resolve? </p>
  
  <p>--EDIT
  If I use https I get <code>cannot read property 'maxCachedSessions'</code></p>
  
  <p>Thanks in advance!</p>