SOCKET ERROR: [Errno 111] Connection dropped Ubuntu

Traceback (most recent call last):
   s = smtplib.SMTP('localhost')
  File "/usr/lib/python2.7/smtplib.py", line 251, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 311, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 286, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 111] Connection refused

      

Q: I am getting this error on my ubuntu machine. The question is, why is this? The reason is that when I execute the same code on Mac OS X 10.7, I don't see this error. And I didn't do any special setting on the Mac for this to work.

+3


source to share


1 answer


Make sure your system is running SMTP server:

netstat -nlt | grep '\<25\>'

      



If your system is running smtp server, the above command will show something like:

tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN     

      

+5


source







All Articles