[Tutor] smtp connection problem --- socket error 10061

Steven D'Aprano steve at pearwood.info
Sat Sep 11 13:18:17 CEST 2010

On Sat, 11 Sep 2010 04:09:20 am goodhei8 at gmail.com wrote:
>   I could not connect with gmail smtp server in Vista 32( worked ok
> in XP 32). Both vista and xp have same anti-virus software.
> >>> smtplib.SMTP("smtp.gmail.com",587)
> Traceback (most recent call last):
>    File "<pyshell#1>", line 1, in <module>
>      smtplib.SMTP("smtp.gmail.com",587)
>    File "C:\Program Files\Python25\lib\smtplib.py", line 244, in
> __init__ (code, msg) = self.connect(host, port)
>    File "C:\Program Files\Python25\lib\smtplib.py", line 310, in
> connect raise socket.error, msg
> error: (10061, 'Connection refused')

Works for me:

>>> import smtplib
>>> smtplib.SMTP("smtp.gmail.com",587)
<smtplib.SMTP instance at 0xb7ca620c>

> I am using IPV4 for my vista wireless connection. No improvement with
> firewall disabled.

Which firewall? On the router, or on Windows?

Perhaps your ISP is blocking the port, or maybe it was just that Gmail 
was not allowing connections at that moment.

Have you verified that you can connect to the server outside of Python 
(say, with telnet)?

> Any one has this problem? any solution?

Have you tried Googling? The second hit for "smtp 10061, 'Connection 
refused'" is this:


Does that help?

Steven D'Aprano

More information about the Tutor mailing list