Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been developing Node.js apps on my localhost on port 1337 for last two years with no problem as shown below.

$ node app
App started on port 1337

Today I wanted to test how things go with default port 80, so I did:

$ sudo node app
App started on port 80

But after that my network went crazy. Now I can't access any local address including localhost. When I ping to localhost it points to some weird public IP address ( instead of

$ ping localhost
PING localhost.local ( 56 data bytes
... is not my public IP address.

When I telnet I see the same wrong IP address:

$ telnet localhost
telnet: connect to address Connection refused
telnet: Unable to connect to remote host

My /etc/hosts is the following:   localhost broadcasthost
::1             localhost
fe80::1%lo0 localhost

Can anybody suggest what's wrong?

I'm completely out of guesses and can't even continue my work.

share|improve this question
up vote 3 down vote accepted

I found the problem. It happens to be the incorrect line endings in /etc/hosts file.

I edited it using Sublime Text 2, which happens to be a wrong choice as it added CR line terminators.

$ file -b /etc/hosts
ASCII English text, with CR line terminators

As mentioned in, it must be only ASCII English text.

So, copying the /etc/hosts contents and overriding this file using "vi", resolved the problem. Now:

$ file -b /etc/hosts
ASCII English text

I hope this will help others as well.

share|improve this answer
you saved my life ! – Suoinguon Jul 25 '14 at 6:21
What a life saver! I cannot thank you enough!!! – iggy2012 Apr 19 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .