Django:ConnectionResetError:[Errno 54]对等重置连接

时间:2020-03-30 09:20:25

标签: django python-3.x django-admin favicon

每当程序调用favicon.ico或任何admin css文件时,我都会收到ConnectionResetError:[Errno 54]对等重置连接

我正在使用

Django==3.0.4
Python 3.6.1

对于以下任何通话

"GET /favicon.ico HTTP/1.1" 404 2104
"GET /static/admin/css/fonts.css HTTP/1.1" 200 423
"GET /static/admin/css/changelists.css HTTP/1.1" 200 4096
"GET /static/admin/css/dashboard.css HTTP/1.1" 200 412
"GET /static/admin/css/widgets.css HTTP/1.1" 200 4096

我收到类似Traceback的错误

Exception happened during processing of request from ('127.0.0.1', 60974)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socketserver.py", line 639
, in process_request_thread
    self.finish_request(request, client_address)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socketserver.py", line 361
, in finish_request
    self.RequestHandlerClass(request, client_address, self)

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socketserver.py", line 696
, in __init__
    self.handle()
  File "/Users/sunilhn/Documents/programming/Envs/proenv/lib/python3.6/site-packages/django/core/s
ervers/basehttp.py", line 174, in handle
    self.handle_one_request()
  File "/Users/sunilhn/Documents/programming/Envs/proenv/lib/python3.6/site-packages/django/core/s
ervers/basehttp.py", line 182, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in r
eadinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer

程序在前端运行正常,没有任何问题。但是控制台中的这个错误困扰着我。

3 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。 在此行之后引发错误:

{ _error: 'message' }

图像在前端加载良好,这是模板代码:

[01/Apr/2020 17:13:16] "GET /static/assets/img/logo-white.png HTTP/1.1" 200 9928

我在标签上添加了一个斜杠,错误消失了。

<img src="{% static 'assets/img/logo-white.png' %}" width="50px" class="logo">

我希望我能解释一下为什么行得通,但没有奏效-如果有人可以启发我,请这样做!

但是把它留在这里以防其他人受益。

答案 1 :(得分:0)

经过验证,我认为在调用 ajax 函数的 html 按钮中将 type="submit" 更改为 type="button" 就可以了。

答案 2 :(得分:0)

我通过禁用 Firefox (87.0) Adblock Plus 扩展解决了这个异常 (ConnectionResetError: [Errno 54] Connection reset by peer)。

(Python==3.7 | Django==2.2)