socket.gethostbyname returns `wrong` result?

Irmen de Jong irmen at -nospam-remove-this-xs4all.nl
Mon Jul 26 18:45:21 EDT 2004


Frank Miles wrote:

> 	import socket
> 	print socket.gethostbyname(socket.gethostname())
> 
> works on my desktop machines and server, on the laptop it gives:
> 	127.0.0.1
> which, of course, doesn't provide any idea as to the state of the network.

Do you have, by any chance, an entry in  your hosts file like this:

127.0.0.1    <real hostname>

If so, remove that line! The hosts file should only contain :

127.0.0.1    localhost

for the 127.0.0.1 address.

-Irmen



More information about the Python-list mailing list