socket.gethostbyaddr() problem

Jason Abate jason at
Thu Feb 3 14:34:02 CET 2000

Thomas Wouters <thomas at> wrote in message
news:20000203091957.A6378 at
> On Wed, Feb 02, 2000 at 05:22:57PM -0600, Jason Abate wrote:
> > I'm having a problem with socket.gethostbyaddr().  If I call it as
> > root, it works fine, but if I call it as non-root, I get the following
> > exception:
> >
> >     socket.gethostbyaddr(socket.gethostname())
> >     socket.error: host not found
> >
> It works fine on my rh6.0 box here:
> >>> socket.gethostbyaddr(socket.gethostname())
> ('', [], [''])
> Did you check /etc/resolv.conf as well? I do get a 'host not found' error
> when my /etc/resolv.conf is unreadable and my hostname is not listed in
> /etc/hosts. If that doesn't fix it, are you using a DNS, or are you
> unconnected and relying entirely on /etc/hosts ? Does it have the proper
> entries for your hostname ?

We finally got this working - the problem turned out to be that our DNS
was not setup to allow reverse lookups on the machine we were testing on,
caused the lookup to fail.  Once we enabled reverse lookups, it worked like
a charm.



Jason Abate
Hostway Corporation
jason at

More information about the Python-list mailing list