Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

the /etc/hosts file contains a line: 127.0.0.1 localhost so localhost should be a valid hostname, but any attempt to connect to a port on localhost fails, including ping.

Connection attempts into this server from outside, using the same clients, work.

Connection attempts from this server to other servers using these clients also work.

On further investigation, it also fails to ping the loopback ip 127.0.0.1 when ping is invoked directly on that ip. In addition to pinging, I tested with 'socat TCP4..'.

Would a bad iptables prevent a localhost connection?

share|improve this question

4 Answers 4

up vote 2 down vote accepted

Is there an interface configured with lo0 or any other interface with 127.0.0.1? Check the Rx packets/Tx packets count. Also, check to see if lo0 is configured in /etc/network/interfaces.

output of 'ifconfig'
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:24 errors:0 dropped:0 overruns:0 frame:0
          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1440 (1.4 KB)  TX bytes:1440 (1.4 KB)
share|improve this answer
2  
@dkeeney -- Apparently this solved your problem, but I can't figure out what part was relevant. Can you elaborate? –  belacq Apr 13 '11 at 21:32

Yes, iptables can firewall localhost from itself. If you've been playing with that, it would be an excellent place to look first.

Try running iptables -L -n. If you're not sure about how to read the output, post it.

A classic mistake is to set the policy to DENY and not to add an exception for localhost.

share|improve this answer

You might look into /etc/resolv.conf , but I don't know which entry would stop localhost from working.

share|improve this answer
    
The resolv.conf file is pretty ordinary, with a couple of nameserver lines. Thanks. –  user14149 Apr 13 '11 at 2:47
    
He's said that he couldn't ping by IP address either, so I doubt it's resolv.conf related. –  belacq Apr 13 '11 at 21:30
    
This information was added later. Yes. –  user unknown Apr 13 '11 at 22:22
    
Ah. Thanks. –  belacq Apr 15 '11 at 16:30

Does 'ip neigh show' show that the loopback interface is up?

Yes, it's possible to configure iptables in such a way as to drop all packets received on lo. I'm not sure how that could take place by accident, but it's worth checking.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.