Patrick Kelly
Patrick Kelly

Reputation: 21

Localhost, [::1], and mapped hosts in etc/hosts work, but 127.0.0.1 does not

The great mystery. I have an Express/Node (v4.2.2) JS app running on OS X El Capitan. The app is running on port 4444. If I run the app, I'm able to get the proper response back with the following commands:

curl localhost:4444 -> Works

curl [::1]:4444 -> Works

curl api.q.com:4444 -> Works

However, I have a problem with:

curl 127.0.0.1:4444 -> Doesn't Work; Responds with curl: (52) Empty reply from server

127.0.0.1:4444 fails in all browsers as well. Even more astonishing, api.q.com:4444 works in all browsers EXCEPT for Chrome.

My /etc/hosts file:

127.0.0.1 localhost web.q.com api.q.com qrm.q.com fhr.q.com

::1 localhost

fe80::1%lo0 localhost

I've tried resetting my /etc/hosts file back to the default and flushed my DNS cache. I have a feeling it might be the app, but I'm not sure what the cause could be. Any suggestions?

Upvotes: 1

Views: 1105

Answers (1)

Patrick Kelly
Patrick Kelly

Reputation: 21

Turns out, it had something to do with a Linux VM I set up in Virtual Box. My /etc/hosts file was the same on that VM (maybe that was the issue?).

I disabled the VM and everything worked again. I have no idea what the cause was, but I'm going to close this question. If anyone else has this issue, I can only suggest look at any VMs you may have running locally. Thanks again!

Upvotes: 1

Related Questions