Question

Django project - gunicorn.socket: Failed with result 'service-start-lim>

I had my site up and running, but the admin CSS was not loading, I am not sure what I did that the server did not agree, but now the entire site is down with a 502 Bad Gateway message. When I type:

sudo systemctl status gunicorn.socket

I get

● gunicorn.socket - gunicorn socket
     Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
     Active: failed (Result: service-start-limit-hit) since Wed 2022-05-11 01:42:19 UTC; 2s ago
   Triggers: ● gunicorn.service
     Listen: /run/gunicorn.sock (Stream)

I did try to restart everything

sudo systemctl daemon-reload 
sudo systemctl restart gunicorn
sudo systemctl enable gunicorn.socket

I still have the same problem. And, when I run: sudo journalctl -u gunicorn.socket

I get this:

-- Logs begin at Tue 2022-02-22 09:51:29 UTC, end at Wed 2022-05-11 01:49:37 UTC. --
May 10 21:53:50 django-s-1vcpu-2gb-sfo3-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-lim>
May 10 23:51:14 django-s-1vcpu-2gb-sfo3-01 systemd[1]: Listening on gunicorn socket.
May 10 23:52:17 django-s-1vcpu-2gb-sfo3-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-lim>
May 11 01:18:28 django-s-1vcpu-2gb-sfo3-01 systemd[1]: Listening on gunicorn socket.
May 11 01:20:47 django-s-1vcpu-2gb-sfo3-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-lim>
May 11 01:35:43 django-s-1vcpu-2gb-sfo3-01 systemd[1]: Listening on gunicorn socket.
May 11 01:36:19 django-s-1vcpu-2gb-sfo3-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-lim>
May 11 01:40:16 django-s-1vcpu-2gb-sfo3-01 systemd[1]: Listening on gunicorn socket.
May 11 01:40:33 django-s-1vcpu-2gb-sfo3-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-lim>
May 11 01:40:51 django-s-1vcpu-2gb-sfo3-01 systemd[1]: Listening on gunicorn socket.
May 11 01:42:19 django-s-1vcpu-2gb-sfo3-01 systemd[1]: gunicorn.socket: Failed with result 'service-start-lim>
lines 1-12/12 (END)

Note that Nginx is OK:

sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

but, when I run the tail command: sudo tail -30 /var/log/nginx/error.log

I get this:

2022/05/11 01:40:50 [crit] 1301736#1301736: *180 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 185.83.186.52, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "128.199.2.252:80"
2022/05/11 01:42:19 [error] 1301736#1301736: *182 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 24.87.145.170, server: www.develuppers.com, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "develuppers.com"
2022/05/11 01:49:37 [crit] 1301736#1301736: *185 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 51.79.29.48, server: _, request: "POST / HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/", host: "128.199.2.252"
2022/05/11 01:49:37 [crit] 1301736#1301736: *187 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client: 51.79.29.48, server: _, request: "GET /.env HTTP/1.1", upstream: "http://unix:/home/django/gunicorn.socket:/.env", host: "128.199.2.252"

This is my gunicorn file:

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

[Service]
User=eson
Group=www-data
WorkingDirectory=/home/eson/develuppers
ExecStart=/home/eson/develuppers/env/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          develuppers.wsgi:application
[Install]
WantedBy=multi-user.target

as per documentation.

Any help is 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
August 22, 2022

Hi @eson,

The error you see the Nginx log

  1. 2022/05/11 01:49:37 [crit] 1301736#1301736: *187 connect() to unix:/home/django/gunicorn.socket failed (2: No such file or directory) while connecting to upstream, client:

suggest an issue with the app itself or Gunicron.

Regarding the error, you see on Gunicron

  1. gunicorn.socket: Failed with result 'service-start-lim>

It’s most often than not connected to ownership or permissions issue. You might want to check that. Additionally, if you open Gunicron’s logs do you see a more specific error?

Try DigitalOcean for free

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

Sign up