Connection reset by peer while reading upstream

How to fix the Connection reset by peer while reading upstream error on Nginx web server.

The error will appear in Nginx error logs as:

failed (104: Connection reset by peer) while reading upstream

Fix Connection reset by peer while reading upstream error

Enable proxy_socket_keepalive

Edit the nginx.conf configuration file to enable the proxy_socket_keepalive parameter:

server {
    location / {
        proxy_socket_keepalive on;
    }
}