Mac OS X 10.7 can't ping/telnet localhost

1

I'm developing using django/postgresql on Mac OS X 10.7 and suddenly I am unable to access the test server through http://localhost:8000/. I can make it listen on 0.0.0.0:8000 and then it works...

Then I noticed problems with SABnzbd starting up. Whenever I try to start it, it dies and shuts down. The logs show

IOError: Port 8080 not bound on '127.0.0.1'

running netstat -an | grep 8080 shows that there is nothing actually listening on port 8080.

I then tried to telnet and ping localhost. Neither work. When I telnet, I get:

$ telnet localhost
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...

and it just hangs there.

When I try to ping I get the following:

$ ping localhost
PING localhost (127.0.0.1): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

The weird thing is that when I telnet to port 80 it works!

$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.

My /etc/hosts file seems normal:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0     localhost

Is there any way for me to fix this problem or is it easiest for me to just wipe it and start again?

Michael

Posted 2012-01-28T07:42:30.900

Reputation: 21

possible duplicate of Mac OS X Mountain Lion can't ping/telnet localhost. Point to a wrong public IP

– fixer1234 – 2015-04-21T02:46:15.340

Answers

2

Most firewalls block ping requests now, my OSX Lion install had that behavior by default too.

Try browsing to http://localhost:80 if you can connect to port 80, and look what's running on that port. Also take look at your Sharing Preferences - there used to be a Web Site sharing feature, and that might be using port 80.

Also, try telnetting to localhost:8080, and see if you can connect (if you can, another app is using that port).

Try to open http://localhost:8080 in your browser then, to try to find out what program is running on that port.

friedkiwi

Posted 2012-01-28T07:42:30.900

Reputation: 281

I can't telnet localhost:8080 or get to http://localhost:8080, both hang there. From what I can see, the firewall is turned off. Am I missing something?

– Michael – 2012-01-28T09:48:53.430

Do you have Little Snitch (or compareable) running - saw that behavior over here too when running that. – friedkiwi – 2012-01-28T09:57:41.330

Nope, I don't even have it on my computer. – Michael – 2012-01-28T10:01:36.507

0

In some cases, this is caused by text-encoding problems; /etc/hosts looks ok but is actually in the wrong encoding. See Mac OS X Mountain Lion can't ping/telnet localhost. Point to a wrong public IP

user4815162342

Posted 2012-01-28T07:42:30.900

Reputation: 101

The question includes command output that shows that "localhost" is getting resolved to 127.0.0.1 and ::1, so that isn't the issue here. – G-Man Says 'Reinstate Monica' – 2015-04-21T06:02:57.327