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 8 13866 ha**********@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
On Aug 27, 12:32 pm, Larry Bates <larry.ba...@websafe.comwrote:
half.ital...@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
On Aug 27, 12:47 pm, half.ital...@gmail.com wrote:
On Aug 27, 12:32 pm, Larry Bates <larry.ba...@websafe.comwrote:
half.ital...@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
I take it back, that wasn't the solution. I got it to work by
haacking smtplib with a static host instead of the
socket.gethostbyname(socket.gethostname()) call...but if I leave that
in there I might get shot one day. What could cause the shell to be
able to resolve the addresses properly, but not python?
nnsswitch.conf ?
I don't know enough about what's going on in the background. Any
other ideas? Or should I try this on a unix board?
~Sean
In message <11**********************@q5g2000prf.googlegroups. com>, ha**********@gmail.com wrote:
What could cause the shell to be
able to resolve the addresses properly, but not python?
nnsswitch.conf ?
How did you test the name resolution in the shell--was it with "host"
or "ping"? I would recommend ping, because that would use the same C
runtime gethostbyname call that your Python code is trying to use.
In article <11**********************@i13g2000prf.googlegroups .com>, ha**********@gmail.com writes:
On Aug 27, 12:32 pm, Larry Bates <larry.ba...@websafe.comwrote:
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- .
On Aug 27, 4:22 pm, s...@signature.invalid (Douglas Wells) wrote:
In article <1188244050.029920.314...@i13g2000prf.googlegroups .com>,
half.ital...@gmail.com writes:
On Aug 27, 12:32 pm, Larry Bates <larry.ba...@websafe.comwrote:
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 ha**********@gmail.com wrote:
On Aug 27, 12:47 pm, half.ital...@gmail.com wrote:
>On Aug 27, 12:32 pm, Larry Bates <larry.ba...@websafe.comwrote:
>>half.ital...@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
I take it back, that wasn't the solution. I got it to work by
haacking smtplib with a static host instead of the
socket.gethostbyname(socket.gethostname()) call...but if I leave that
in there I might get shot one day. What could cause the shell to be
able to resolve the addresses properly, but not python?
nnsswitch.conf ?
I don't know enough about what's going on in the background. Any
other ideas? Or should I try this on a unix board?
Well the first thing to do is call socket.gethostname() and see what it
returns, then call socket.gethostbyname() on the result. Once you know
what's failing we might be able to help.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
In article <11*********************@l22g2000prc.googlegroups. com>, ha**********@gmail.com writes:
On Aug 27, 4:22 pm, s...@signature.invalid (Douglas Wells) wrote:
In article <1188244050.029920.314...@i13g2000prf.googlegroups .com>,
half.ital...@gmail.com writes:
On Aug 27, 12:32 pm, Larry Bates <larry.ba...@websafe.comwrote:
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')
~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
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
That would be a reasonable workaround. The process of sending
e-mail via SMTP could need the local host name for at least two
uses: 1) the SMTP initial connection (RFC 2821) requires the
client to identify itself (provide its host name); 2) the mail
headers (RFC 2822) should include a return address, which probably
defaults to using your user name at your client host name.
The hostname of your system (00:17:08:5E:EF:0F) is silly when used
with SMTP. Your system administrator is either ill-informed or is
actively trying to prevent users from using their systems as
servers. It has the form of an IPv6 numeric host address.
Given the pathnames in your command interchange, you have a UNIX,
Linux, or UNIX-like system. According to the Linux and UNIX standards:
- If your system is IPv6-capable, the use of such a name with
gethostbyname invokes "unspecified behavior." First, the function
is not defined to work with such "numeric" identifiers. Second,
it is not guaranteed to work with non-IPv4 names, and probably
can't be registered in pre-i18n DNS data bases.
- Even if your system is not IPv6-capable, such a host name is going
to confuse many other systems that would be IPv6-capable and attempt
to resolve the odd-ball name that your system provides.
- Even if that worked, you're providing an IPv6 name form in
conjunction with an IPv4 protocol (at least when you explicitly
provide the IP address as a dotted-quad).
- dmw
--
.. Douglas Wells . Connection Technologies .
.. Internet: -sp9804- -at - contek.com- . This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eric Brunel |
last post by:
Hi all,
I just compiled Python 2.3.2 on Linux Mandrake 8.0, upgrading from Python 2.1. I
have one problem that I can't figure out: when I wanted to get "the" IP address
of the current host with...
|
by: Jacob Lee |
last post by:
I'm getting a rather bizarre error while using the socket module. If I
start out disconnected from the net and then connect while the program or
interpreter session is open, I do not always gain...
|
by: Sheila King |
last post by:
I'm doing DNS lookups on common spam blacklists (such as SpamCop..and
others) in an email filtering script. Sometimes, because the DNS server
that is resolving the looksup can go down, it is...
|
by: spamsink42 |
last post by:
this code
h=httplib.HTTPConnection('euronext.com')
h.request('GET',
'http://www.euronext.com/home/0,3766,1732,00.html')
fails with this message
File "httplib.py", line 532, in connect...
|
by: Mark Fink |
last post by:
I try to port a server application to Jython. At the moment I use
Jython21\Lib\socket.py
Currently I do face problems with casting the string "localhost" to the
desired value:...
|
by: flamesrock |
last post by:
Hi,
Basically, I'm trying to send a multipart form to a server using some
code from aspn.. here it is:
MultipartPostHandler: http://pastie.caboo.se/29833
import MultipartPostHandler, urllib2,...
|
by: John Nagle |
last post by:
Here's a strange little bug. "socket.getaddrinfo" blows up
if given a bad domain name containing ".." in Unicode. The
same string in ASCII produces the correct "gaierror" exception.
Actually,...
|
by: John Nagle |
last post by:
Here are three network-related exceptions. These
were caught by "except" with no exception type, because
none of the more specific exceptions matched. This
is what a traceback produced:
1....
|
by: Python Programming on Win32 |
last post by:
Hi,
I have encountered a problem which I can not figure out a solution
to.
Tried Googeling it, but to no help unfortunately.
The problem is running smtplib in a py2exe compiled exe file. When...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |