调试时遇到一些问题。当我第一次启动我的应用程序时,我总是收到此错误,然后间歇性地收到此错误。有人可以通过抛出一些调试技术来帮助我吗?我试过使用代理检查器 - 无济于事,我没有看到任何有用的东西。我已经尝试了关于在我的 Django 设置中设置我的 SITE_URL 的建议。我试过有和没有 http://有和没有端口...这是无用的错误:
Exception happened during processing of request from ('127.0.0.1', 57917)
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__
self.handle()
File "/Users/ryan/.local/share/virtualenvs/portal-2PUjdB8V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle
self.handle_one_request()
File "/Users/ryan/.local/share/virtualenvs/portal-2PUjdB8V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
即使此连接重置,该应用程序似乎也能正常运行,但它一直让我疯狂地尝试调试。
最佳答案
FFS... 太蠢了。我注意到它总是在找不到 favicon 后重置,所以我添加了一个...即使我从未明确加载过一个,django 似乎尝试从项目的根目录加载一个默认的...这不会发生对于从事该项目的任何其他开发人员。诡异的。 (为了完整起见)如果其他人偶然发现了这个,我使用了 favicon io制作一个简单的文本。然后我像这样将它加载到我的 html 中:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />
...
请务必在设置中正确设置您的静态路径。
关于Python Django Errno 54 'Connection reset by peer',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57261024/