I'm having difficulties understanding why the following line of code works in node.js:
server.listen(12345, "127.0.0.1"); // works
but this one does not:
server.listen(12345, "localhost"); // fails
Coding localhost
literally results in the following error thrown:
events.js:45
throw arguments[1]; // Unhandled 'error' event
^
Error: ECONNREFUSED, Could not contact DNS servers
at IOWatcher.callback (dns.js:74:15)
I do not understand why it should 'contact DNS servers' as it's localhost as defined in my HOSTS
file (I'm using node.js under Windows).
Why doesn't hardcoding localhost
work?
It turned out that using the cygwin build was the problem.
I looked at http://nodejs.org/ and I discovered that only recently a native Windows binary file was made available, which works like a charm.