This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Erratic socket.gaierror: [Errno 11004] when using smtplib
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: David.Ward, neologix, pitrou
Priority: normal Keywords:

Created on 2011-07-17 11:39 by David.Ward, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg140525 - (view) Author: David Ward (David.Ward) Date: 2011-07-17 11:39
When migrating from python 2.7.1 to 2.7.2 (or 3.2) I get unpredictable /erratic exceptions thrown on constucting smtplib.SMTP:

socket.gaierror: [Errno 11004] getaddrinfo failed 

Here is the call stack:

  File "**********\mail.py", line 41, in Mail
    server = smtplib.SMTP(MAILSERVER)
  File "c:\python27\lib\smtplib.py", line 250, in __init__
    (code, msg) = self.connect(host, port)
  File "c:\python27\lib\smtplib.py", line 306, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "c:\python27\lib\smtplib.py", line 284, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "c:\python27\lib\socket.py", line 380, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed

MAILSERVER is a local address. There are no known DNS issues on our local network. 

If I try to reduce the code to a small repro (e.g. sending mail in a loop or calling getaddrinfo), I cannot reproduce the problem.

This code had worked unchanged for many years and many previous python releases all the way back to 2.3.

Platform is Windows 7 x64, AMD64 build of python 2.7.2 (or 3.2).

Reverting back to 2.7.1 solves the problem.
msg140526 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-07-17 12:47
This sounds rather strange. There haven't been any significant changes in smtplib or the socket module between 2.7.1 and 2.7.2.
msg146775 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-11-01 14:04
Please provide more information, because this looks really strange...
History
Date User Action Args
2022-04-11 14:57:19adminsetgithub: 56787
2011-11-23 18:20:06neologixsetstatus: pending -> closed
resolution: not a bug
stage: test needed -> resolved
2011-11-01 14:04:01neologixsetstatus: open -> pending

nosy: + neologix
messages: + msg146775

stage: test needed
2011-07-17 12:47:34pitrousetnosy: + pitrou
messages: + msg140526
2011-07-17 11:39:39David.Wardcreate