Why can't browsers resolve localhost?
First check name resolution with the system resolver:

dscacheutil -q host -a name localhost


If you get an output like:

name: localhost
ipv6_address: ::1

name: localhost
ip_address: 127.0.0.1


the system resolver works correctly.

Stop your node.js app, create a simple node.js server by using this file with an arbitrary name (e.g. multiserver.js):

var http = require('http');
function handler(req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
};
http.createServer(handler).listen(3000, '127.0.0.1');
http.createServer(handler).listen(3001, 'localhost');
http.createServer(handler).listen(3002, '192.168.0.5');
http.createServer(handler).listen(3003, 'host.example.com');
http.createServer(handler).listen(3004, 'LocalHostName.local');


(replace the IP of the :3002 server by an IP of your host (ifconfig), the host.example.com of the :3003 server by the output of echo $HOSTNAME and LocalHostName by the output of scutil --get LocalHostName)

and start it with

node ../multiserver.js


Now test your "multiserver" with Google Chrome by entering http://name:port (don't forget to prepend http://).

The first two ports should work with both "names" (127.0.0.1/localhost). So entering either http://127.0.0.1:3000, http://127.0.0.1:3001, http://localhost:3000 or http://localhost:3001 should all yield "Hello World".

Also check the nine permutations of the next three ports and names (e.g. http://LocalHostName.local:3002 or http://192.168.0.5:3004) which should also all yield "Hello World" if the hostname/DNS are set up correctly.

If all this works, your express/node.js app is faulty.