首页 > 解决方案 > Digital Ocean 连接上的 Django 服务器被对等方重置

问题描述

我正在尝试使用 Django 2.0.4 和 Ubuntu 16.0.4 液滴在我的数字海洋实例上设置 django 服务器。我以 root 身份 ssh 进入 droplet 并使用以下命令启动服务器

python manage.py runserver 0.0.0.0:80

django 服务器可以正常启动。但是几秒钟后,我没有做任何事情,这些错误会反复出现:

----------------------------------------
----------------------------------------
Exception happened during processing of request from ('175.100.8.37', 12774)
Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 625, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
    self.handle()
  File "/root/website/back-end/env/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 139, in handle
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('175.100.8.37', 12775)
Traceback (most recent call last):
  File "/usr/lib/python3.5/socketserver.py", line 625, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.5/socketserver.py", line 354, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.5/socketserver.py", line 681, in __init__
    self.handle()
  File "/root/website/back-end/env/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 139, in handle
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 104] Connection reset by peer
----------------------------------------

这是我的ALLOWED_HOSTS设置:

ALLOWED_HOSTS = [
    "tedxuwa.com",
    "www.tedxuwa.com",
    "localhost:8000"
]

DEBUG设置为 False,我绝对不是提出这些请求的人。为什么会发生这些错误?

标签: pythondjangodigital-ocean

解决方案


推荐阅读