ConnectionResetError: [Errno 54] Connection reset by peer

Periodically, while running the development server (eg, manage.py runserver 8080), I’m getting errors like the following:

----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 57240)
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 650, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socketserver.py", line 720, in __init__
    self.handle()
  File "/usr/local/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 174, in handle
    self.handle_one_request()
  File "/usr/local/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
    self.raw_requestline = self.rfile.readline(65537)
  File "/usr/local/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------

Despite these errors, the development server appears to be running fine: the requested pages get displayed and behave correctly. It’s just driving me nuts to have these unexplained errors cluttering the server’s console.

And, believe me, I’ve combed through Stackoverflow to no avail. None of the suggestions that I found there (make sure that you have a favicon.ico file, that you’re serving static files correctly, that your <img /> tags have a closing /, etc.) have helped.

I’m using Django 3.1.5 and Python 3.9.1 on MacOS 11.1, if that makes a difference. MySQL 8.0.23 was installed via Homebrew, and is also running on localhost.

Does anyone have any suggestions on how to eliminate these error messages?

4 Likes