Ask Your Question
0

AttributeError: SMTP instance has no attribute 'sock'

asked 2013-12-05 17:06:27 -0500

odyssey gravatar image

After some minutes starting the server (tried with gunicorn, uwsgi, mod_wsgi) I get this error. Why does it work normally but stop working after some time?

Traceback (most recent call last):
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 131, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/handlers/wsgi.py", line 255, in __call__
    response = self.get_response(request)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/handlers/base.py", line 178, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/handlers/base.py", line 212, in handle_uncaught_exception
    'request': request
  File "/usr/lib/python2.7/logging/__init__.py", line 1166, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
    self.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
    self.callHandlers(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
    self.emit(record)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/utils/log.py", line 113, in emit
    mail.mail_admins(subject, message, fail_silently=True, html_message=html_message)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/__init__.py", line 98, in mail_admins
    mail.send(fail_silently=fail_silently)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/message.py", line 255, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/backends/smtp.py", line 99, in send_messages
    self.close()
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/backends/smtp.py", line 72, in close
    self.connection.close()
  File "/usr/lib/python2.7/smtplib.py", line 747, in close
    if self.sock:
AttributeError: SMTP instance has no attribute 'sock'
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-06-07 03:35:30 -0500

AJJ gravatar image

updated 2014-06-07 03:36:41 -0500

I have just come across and solved a problem that was throwing this same traceback. The error was indeed unrelated to SMTP. You see that email-related error for the simple fact that django is trying to log the exception via its default logging configuration which includes sending an email to the admins of the site.

To help me in debugging my problem, I set DEBUG=True in settings and I then got the real problem reported: a couple of missing settings.

edit flag offensive delete link more
0

answered 2013-12-09 23:51:10 -0500

JStarcher gravatar image

I've seen this error a few times and usually its because of an import error somewhere. Based on my experience is unlikely the error has and thing to do with SMTP. I also saw this when my database was misconfigred have you made any code or configuration changes recently?

edit flag offensive delete link more

Comments

nope, there seems to be some other concealed exceptions. How one deals with those mysterious errors I am yet to find out.. For example following the advice on skin creation at wiki I made a skin folder copying templates and stuff. Now when I update the email of a user for example via admin interface i get jinja2.exceptions.UndefinedError: 'skin' is undefined I wonder if this has anything to do with skins

odyssey gravatar imageodyssey ( 2013-12-10 01:10:30 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-12-05 17:06:27 -0500

Seen: 2,907 times

Last updated: Jun 07 '14