Question

gunicorn - failure: Connection reset by peer

Deploying a django project to my droplet I encounter a gunicorn issue:

curl --unix-socket /run/gunicorn.sock localhost
curl: (56) Recv failure: Connection reset by peer

This error is raised when by the command: curl --unix-socket /run/gunicorn.sock localhost

According to online forums, this issue is related to the path of my gunicon. gunicron-path

However, my gunicron is set exactly by this path: That is the file -sudo nano /etc/systemd/system/gunicorn.service displays:

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=nuser
Group=www-data
WorkingDirectory=/home/nuser/pipit
ExecStart=/home/nuser/pipit/.venv/bin/gunicorn \
        --access-logfile - \
        --workers 3 \
        --bind unix:/run/gunicorn.sock \
        pipit.wsgi:application

[Install]
WantedBy=multi-user.target

Any advise as on how I can fix it would be highly appreciated.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
May 8, 2023

Hey @leacards,

Usually, the error # Connection reset by peer is related to your Application as a whole rather than configuration.

Check the logs of your Gunicorn application as well as the Nginx logs to see for a more concrete error.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel