MunirohMansoor
MunirohMansoor

Reputation: 355

django sending mail [Errno -2] Name or service not known

i'm using django-registration in my project to sending email when user forgot password. But i got the error [Errno -2] Name or service not known. Below are my settings and traceback..

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587

gaierror at /accounts/password_reset/
    [Errno -2] Name or service not known
    Request Method: POST
    Request URL:    http://localhost:8000/accounts/password_reset/
    Django Version: 1.10.5
    Exception Type: gaierror
    Exception Value:    
    [Errno -2] Name or service not known
    Exception Location: /usr/lib/python2.7/socket.py in create_connection, line 553
    Python Executable:  /usr/bin/python
    Python Version: 2.7.6
    Python Path:    
    ['/vagrant/ifoswork/ifoswork',
     '/usr/lib/python2.7',
     '/usr/lib/python2.7/plat-x86_64-linux-gnu',
     '/usr/lib/python2.7/lib-tk',
     '/usr/lib/python2.7/lib-old',
     '/usr/lib/python2.7/lib-dynload',
     '/usr/local/lib/python2.7/dist-packages',
     '/usr/lib/python2.7/dist-packages']
    Server time:    Thu, 5 Oct 2017 14:38:34 +0800

Upvotes: 1

Views: 5335

Answers (1)

Robotichead
Robotichead

Reputation: 148

When I got this error it was caused by the wrong information in the following fields:

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587

Except I am not using gmail, however I did find the following information on Django 1.8 sending mail using gmail SMTP

Go to your Google Account settings, find Security -> Account permissions -> Access for less secure apps, enable this option.

Essentially the error "[Errno -2] Name or service not known" can not connect to the email server.

Upvotes: 2

Related Questions