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

62o28rlo  于 2023-08-08  发布在  Go
关注(0)|答案(2)|浏览(93)

我试图实现django-registration,但我在注册页面上得到了一个gaierror,其中包含以下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

字符串
以下是我的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 = '/'


我应该在哪里检查才能找到错误?

uqcuzwp8

uqcuzwp81#

我面临着同样的问题,这只是一个不稳定的互联网连接,因为问题消失了,因为我改变了我的连接。

qnakjoqk

qnakjoqk2#

嗨,我遇到了一个类似的问题,我已经阻止了除了端口80和443之外的所有端口,但我的项目依赖于外部服务与另一个端口。您可以暂时禁用ufw并检查是否一切正常。

sudo ufw disable

字符串

相关问题