I've got a program on my machine listening on port 8080 to respond to HTTP requests. But when I try to go to
http://localhost:8080/ in a browser...
The localhost page isn’t working
localhost didn’t send any data. ERR_EMPTY_RESPONSE
Firefox redirects the request to www.localhost.com:8080 which of course isn't correct. My research suggests that it is doing this because it can't find localhost.
Safari says it can't open the page because "the server unexpectedly dropped the connection."
However, if I go to
http://127.0.0.1:8080 the page loads correctly.
Therefore, it would seem that for some reason OS X isn't properly resolving localhost to 127.0.0.1. If I try to
ping localhost from the command line, it works, but my understanding is that name resolution works differently in different places.
I have read various issues where localhost doesn't resolve e.g. from ping, but I am not having that problem. All the cases where localhost were not working in the browser appear to not have solutions related to the actual problem I am having. I have also seen places where people have mentioned that localhost does work in the browser, so I am wondering what I am doing wrong here.
If I try the IPv6 address for localhost
http://[::1]:8080/ then I get the same errors as using localhost.