You can do this to get more error information.
.on('error',function(e){ console.log("Error: " + hostNames[i] + "\n" + e.message); console.log( e.stack ); });
If you specify a non-existent URL, the code is returned:
getaddrinfo ENOTFOUND Error: getaddrinfo ENOTFOUND at errnoException (dns.js:37:11) at Object.onanswer [as oncomplete] (dns.js:124:16)
The error is called from the http.ClientRequest class at http.request (). No 404 will generate this error. Error 404 means that the client was able to contact the server, but the server could not find the requested one. This error means that the domain name system could not find the address (dns.js for NAPTR ).
user568109
source share