[英]WinError 10061 No connection could be made because the target machine actively refused it
[英]"[WinError 10061] No connection could be made because the target machine actively refused it"
我突然开始收到上述错误消息,完全没有理由。 我推测我的数据库已损坏并将其删除并重新启动。 当失败时,我查看了我的防火墙部分。 我把它们都关掉了,问题仍然存在。
我正在关注 Udemy 教程并从 Github 复制和粘贴代码。 我们添加了代码以在用户注册时发送确认电子邮件。 当我观看视频时,我错过了这个细节。 我不知道我们现在正在发送注册电子邮件。 我遇到了这个问题,因为我在使用 LOCALHOST 时无法发送确认电子邮件。
如果您收到此错误并且像我一样不知道为什么会收到它。 然后按 CTRL + Shift + F(查找),看看你是否能发现任何提及电子邮件的地方。
我添加了一个 if 语句,当我在 LOCALHOST 上运行我的网站时,它现在可以防止代码尝试发送电子邮件。
def post_save_user_create_reciever(sender, instance, created, *args, **kwargs):
if created:
obj = EmailActivation.objects.create(user=instance, email=instance.email)
EMAIL_PORT = getattr(settings, 'EMAIL_PORT', 0)
if EMAIL_PORT == 587:
obj.send_activation()
如果您尝试发送电子邮件,则需要修改设置文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.