Vasile
Vasile

Reputation: 841

Django-registration "gaierror at /accounts/register/ [Errno -2] Name or service not known"

I am trying to implement django-registration, but I get a gaierror on the registration page with the following traceback:

Internal Server Error: /accounts/register/
Traceback (most recent call last):
  #irlevant
  File "/usr/local/lib/python2.7/dist-packages/registration/views.py", line 36, in form_valid
    new_user = self.register(form)
  File "/usr/local/lib/python2.7/dist-packages/registration/backends/model_activation/views.py", line 29, in register
    site=get_current_site(self.request)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 184, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/registration/models.py", line 97, in create_inactive_user
    registration_profile.send_activation_email(site)
  File "/usr/local/lib/python2.7/dist-packages/registration/models.py", line 182, in send_activation_email
    self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 363, in email_user
    send_mail(subject, message, from_email, [self.email], **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/core/mail/__init__.py", line 61, in send_mail
    return mail.send()
  File "/usr/local/lib/python2.7/dist-packages/django/core/mail/message.py", line 292, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
    new_conn_created = self.open()
  File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 58, in open
    self.connection = connection_class(self.host, self.port, **connection_params)
  File "/usr/lib/python2.7/smtplib.py", line 256, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.7/smtplib.py", line 316, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.7/smtplib.py", line 291, in _get_socket
    return socket.create_connection((host, port), timeout)
  File "/usr/lib/python2.7/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
gaierror: [Errno -2] Name or service not known

Here is my settings.py:

DEBUG = True

ALLOWED_HOSTS = ['*']


EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '********@gmail.com'
EMAIL_HOST_PASSWORD = '*******'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
ACCOUNT_ACTIVATION_DAYS = 1
REGISTRATION_AUTO_LOGIN = True
SITE_ID = 1
LOGIN_REDIRECT_URL = '/'

Where should i check to find the mistake?

Upvotes: 0

Views: 2640

Answers (2)

Laban
Laban

Reputation: 2502

Hi i faced a similar problem i had blocked all ports except port 80 and 443 yet my project depended on external a service with another port. You can temporarily disable ufw and check if everything is fine.

sudo ufw disable

Upvotes: 0

Akbar BadShah
Akbar BadShah

Reputation: 21

I faces the same problem, it was just an unstable internet connection because the problem disappeared as I changed my connection.

Upvotes: 0

Related Questions