Python gethostbyname fails just one one machine.

abhishes at gmail.com abhishes at gmail.com
Wed Dec 17 22:21:22 EST 2014


I have many machines on which the following command returns nothing (but does not throw an error as well

python -c 'import socket; socket.gethostbyname(socket.getfqdn())'


but on just one machine. this command throws

Traceback (most recent call last):
  File "<string>", line 1, in <module>
socket.gaierror: [Errno -3] Temporary failure in name resolution


I searched the internet and most people had this problem because of a bad /etc/hosts file or /etc/sysconfig/network file

but in my case this files are absolutely correct

/etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
156.17.148.40 cm1work
156.17.148.41 hd1work
156.17.148.42 hd2work
156.17.148.43 hd3work

/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=h3work
GATEWAY=156.17.148.1

but this command just won't work

Please help me out.....
~



More information about the Python-list mailing list