Python Django Errno 54 Connection reset by peer

Python Django Errno 54 Connection reset by peer

FFS… so dumb. I noticed that it was always resetting after not finding a favicon so I added one… Even though I never explicitly loaded one, django appears to try and load a default one from the root of the project… This doesnt happen for any of the other devs working on the project either. weird.
(For completeness) If anyone else stumbles upon this i used favicon io to make a simple text one. Then i loaded it into my html like so:

{% load static %}
<!DOCTYPE html>
<html lang=en>

  <link rel=shortcut icon href={% static images/favicon.ico %} />

Be sure to set your static path correctly in settings.

The same behaviour is seen if the favicon is in .png format as opposed to .ico.

Also, contrary to advice seen on other sites, downgrading Python to v3.6 does not solve the problem. screenshot of error w. png favicon

Seems to be a Django issue, It will probably be fixed permanently in a future Django release.

Following I made the changes shown:

I then replaced BrokenPipeError with ConnectionAbortedError. This seems to handle the exception.

Update for Django 3: I have the following changes in (rev.1.2.1) to get rid of all the pesky broken pipe error messages:

Line 55: - return issubclass(exc_type, BrokenPipeError)
Line 55: + return issubclass(exc_type, (BrokenPipeError, ConnectionAbortedError, ConnectionResetError))

Line 71: - Broken pipe from %sn, client_address)
Line 71: + pass

Python Django Errno 54 Connection reset by peer

I came across the same issue ConnectionResetError: [Errno 54] Connection reset by peer.

In my case the issue was trying to serve static files through development server with debug settings to False, development server can serve static files only when debug is set to True in settings file.

In my settings file i replace

DEBUG = False


DEBUG = True

After that, I restart my development server and it works for me!

Leave a Reply

Your email address will not be published. Required fields are marked *