Re: Socket - gaierror



On Aug 27, 4:22 pm, s...@xxxxxxxxxxxxxxxxx (Douglas Wells) wrote:
In article <1188244050.029920.314...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,



half.ital...@xxxxxxxxx writes:
On Aug 27, 12:32 pm, Larry Bates <larry.ba...@xxxxxxxxxxx> wrote:

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!

~Sean

Note that the lookup is of your *local* system name
(socket.gethostname()). I suspect that the name of your client
system (the one running the python script) is not registered in
DNS.

Try ping'ing your own system and see if that resolves in DNS. In
UNIX/Linux you can use the hostname command; in any system you can
write a python script to print the result of socket.gethostname().

- dmw

--
. Douglas Wells . Connection Technologies .
. Internet: -sp9804- -at - contek.com- .

I found a solution...but still not sure why that happened.

root@00:17:08:5E:EF:0F:/usr/local/sw/program/bin# hostname
00:17:08:5E:EF:0F
root@00:17:08:5E:EF:0F:/usr/local/sw/program/bin# ping 00:17:08:5E:EF:
0F
ping: unknown host 00:17:08:5E:EF:0F

socket.gethostname()
'00:17:08:5E:EF:0F'

Workaround: pass the 'local_hostname' arg to the smtplib.SMTP() call
with "localhost"

ie smtp.SMTP("some.computer", local_hostname="localhost")

This is just overriding the socket.gethostname() call entirely.

Did a bit of testing with the /etc/hosts file, and even with an entry
to the hostname it can't resolve the ip.
The problem is the name "00:17:08:5E:EF:0F" PS. I didn't choose to
set the hostname that way.

~Sean

.



Relevant Pages

  • Re: adding a second nic
    ... > internal Active Directory domain zone. ... with a gateway of 192.168.1.1 and assign it in DNS as a domain name ... and use that as my internet connection ... on 192.168.1.200 called outside, with hostname ohostname. ...
    (microsoft.public.win2000.dns)
  • Re: Security flaw in ALCATEL/THOMSON Speed Touch Pro ADSL modems
    ... | because it's a way DHCP and DNS are supposed to work and it's ... firmware simply doesn't validate any further Hostname given to it, ... this flaw allows to corrupt the local zone file ...
    (Bugtraq)
  • Re: Bug in Graphical Network Configuration???
    ... I have assigned the static address for my FC5 box because I am serving ... FC5 box has something to do with the Samba since windows machines uses ... addresses - it might add them (machine hostname and FQDN) to the ... The ISP's DNS server numerical IP addresses. ...
    (Fedora)
  • Re: IP ADDRESS
    ... to me with the least amount of client machine configuration or programming. ... machines in DNS or RDNS, or that you have them all in DNS & RDNS. ... GET THE HOSTNAME FOR THE DEVICE ... FOR PTR = 1 TO LNS ...
    (comp.databases.pick)
  • Re: URLs and Sets do not mix - DNS lookups are compulsory
    ... and the DNS resolution was taking some time to ... the hostname is specified. ... the environment, with no access to the internal DNS servers. ... Store the string verion of the URL instead of the URL itself. ...
    (comp.lang.java.programmer)