node.js - I am getting `getAddrInfo ENOTFOUND localhost` on running simple node server even though localhost is present in /etc/hosts (MacOS El Capitan) -
i have weird thing happening while setting , running normal node js server.
when run node server.js
, following error:
server running @ http://localhost:1337/ events.js:160 throw er; // unhandled 'error' event ^ error: getaddrinfo enotfound localhost @ errnoexception (dns.js:28:10) @ getaddrinforeqwrap.onlookup [as oncomplete] (dns.js:76:26)
when open http://localhost:1337/
in browser, says page not exist
.
when run sudo node server.js
, runs fine without error , can access site @ https://localhost:1337
here /etc/hosts file:
127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost
my server.js:
// require need var http = require("http"); // build server var app = http.createserver(function(request, response { response.writehead(200, { "content-type": "text/plain" }); response.end("hello world!\n"); }); // start server, baby app.listen(1337, "localhost"); console.log("server running @ http://localhost:1337/");
other details
- os: mac os (el capitan)
- node js version: 6.10.3 (installed globally)
- npm version: 4.5.0 (installed globally)
following questions
- why above server.js file working admin access not normal user?
- does globally installed node work admin access?
- is there else in mac os can affect dns lookup other /etc/hosts? have flushed dns cache , reboot os make sure older dns lookup not being used.
Comments
Post a Comment