views:

34

answers:

1

I've got a laptop and a desktop, both running Ubuntu 10.04, both running the stock Python 2.6.5 that comes with Ubuntu.

On the laptop, the following program

#!/usr/bin/env python
import socket
print(socket.getaddrinfo("localhost", 8025, 0, socket.SOCK_STREAM))

works -- i.e., it prints out some stuff without getting an error.

The stuff, in fact, is:

[(10, 1, 6, '', ('::1', 8025, 0, 0)), (2, 1, 6, '', ('127.0.0.1', 8025))]

(That's one bunch of IPv6 data, and one bunch of IPv4 data.)

However, on the other box, the same program does this:

Traceback (most recent call last):
  File "socktest.py", line 5, in <module>
    print(socket.getaddrinfo("localhost", 8025, 0, socket.SOCK_STREAM))
socket.gaierror: [Errno -2] Name or service not known

Why?

The laptop is x86 (i.e., 32-bit) whereas the desktop is x86_64, but I'd be surprised if that mattered. The laptop also has two network interfaces (wireless and wired), whereas the desktop just has wired; again I doubt that's relevant. All three interfaces were bound to IPv6 addresses, according to "ifconfig". I diffed /etc/network on the two boxes, and saw no difference, except that the laptop has this clause

# The primary network interface
auto eth0
iface eth0 inet dhcp

... which, again, strikes me as irrelevant.

::

If you want some context: my Python program is trying to send email, and it's the email software that is ultimately calling getaddrinfo.

+1  A: 

Check /etc/hosts on the box where it does not work. Is there an entry for localhost?
Also compare /etc/nsswitch.conf and see if there is anything suspicious, like missing 'hosts' line

unbeli
/etc/hosts is identical on both boxes, other than whitespace and the actual host names. Each has two entries for "localhost": one for IPv4 and one for IPv6./etc/nsswitch.conf is identical on both boxes; each has a "hosts:" line.
offby1
Can you do telnet localhost 8025 on both?
unbeli