node.js - NodeJS DNS error: ENOTFOUND -


i follwing error: getaddrinfo enotfound. url trying connect subdomain on https.

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) => {       console.log('statuscode: ', res.statuscode);       console.log('headers: ', res.headers);        res.on('data', (d) => {         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 ); }); 

i have tried many things, path, hostname etc. when use fiddler need set proxy, , fiddler resolve hostname of test.printapi.nl, , authenticate. when node needs it, not find right dns record.

i have tried dns.getservers(), , did return correct dns server. tried google dns servers, , did not help. overlooking need set hostname resolve?

--edit if use https cannot read property 'maxcachedsessions'

thanks in advance!

enotfound means no dns entry found hostname. problem in case hostname should not include path. instead should like:

var options = {   hostname: 'test.printapi.nl',   path: '/v1/oauth'   // ... 

also, don't need explicitly set host header. port number disagrees module you're using -- if it's https connection, use https.request() instead of http.request().

lastly, can either remove or need change line:

options.agent = http.agent(options); 

to this:

options.agent = new https.agent(options); 

Comments