Socket - gaierror
half.italian at gmail.com
half.italian at gmail.com
Mon Aug 27 15:47:30 EDT 2007
On Aug 27, 12:32 pm, Larry Bates <larry.ba... at websafe.com> wrote:
> half.ital... at gmail.com wrote:
> > Hi all,
>
> > I'm having trouble with the socket module resolving a hostname. It
> > seems like this is a system level problem, but I'm not even sure where
> > to start. I can ping the smtp server by name and IP, but when
> > smtp.SMTP("theHost") tries to get the hostname, it keeps giving me the
> > following error:
>
> > File "bin/program.py", line 123, in notify
> > smtp = smtplib.SMTP("theHost")
>
> > File "/usr/lib/python2.4/smtplib.py", line 255, in __init__
> > addr = socket.gethostbyname(socket.gethostname())
>
> > gaierror: (-2, 'Name or service not known')
>
> > I tried changing to a different smtp server, using an ip instead of a
> > host name. I could ping both boxes by name oor IP.
>
> > any ideas?
>
> > ~Sean
>
> The specific error shown is a DNS resolution problem. Based on the
> URL "theHost" smtplib can't resolve to an IP address (which is what
> socket.gethostbyname does). You don't say what happened when you changed to ip,
> but I suspect it is a different error or some other problem. Maybe a firewall
> issue (port 25 not open?), but I'm just guessing.
>
> -Larry
Changing it to IP gives me the same exact error...
File "bin/prgram.py", line 123, in notify
smtp = smtplib.SMTP("XXX.XXX.XXX.XXX")
File "/usr/lib/python2.4/smtplib.py", line 255, in __init__
addr = socket.gethostbyname(socket.gethostname())
gaierror: (-2, 'Name or service not known')
Looks like the smtp port is closed on the client machine...doh Should
have gotten to that!
Thank you.
~Sean
More information about the Python-list
mailing list