gunicorn.socket: Failed with result 'service-start-limit-hit'
Asked Answered
J

3

18

I was deploying a django app and it failed because for some reason the gunicorn.socket file was not created even though before adding nginx it worked perfectly fine so I searched the internet and found this answer where the guy says that the reason for this is the virtual environment but I'm sure there must be a way around it using venv right?

the log I get from nginx:

connect() to unix:/run/gunicorn.sock failed (11 1: Connection refused) while connecting to upstream,

error from gunicorn:

gunicorn.socket: Failed with result 'service-start-limit-hit'.

I'm 100% sure the problem is with gunicorn not with the setup of nginx becuase I did check for the gunicorn file and it did not exist.

Jasen answered 10/3, 2019 at 23:55 Comment(0)
C
24

I don't know django, but I am going to assume that this issue is similar to an issue I saw trying to get the MySQL service to start on one of my servers today (see here: https://mcmap.net/q/740982/-couchdb-service-failed-with-result-39-start-limit-hit-39)

Basically, the "start-limit-hit" message is a red herring - service start tries to start which ever service name you provide multiple times, and if after the fifth failed attempt (for me, at least) it crashes out on the sixth attempt with "start-limit-hit". You'll need to investigate the actual syslog (possibly /var/log/syslog) to see what the real errors are that are preventing the service from starting on attempts 1-5.

Calvities answered 13/3, 2019 at 12:22 Comment(1)
In my case, I didn't actually have gunicorn in my Pipfile, and I assumed it was.Egad
N
1

Check whether you have proper permissions for the user/group mentioned inside the gunicorn.service file.

I had the same issue, my gunicorn file had:

[Service]
User= www-data 
Group= www-data

I changed the permission of gunicorn service file, socket file and django directory and it worked fine.

chown www-data:www-data /etc/systemd/system/gunicorn.service
chown www-data:www-data /etc/systemd/system/gunicorn.socket
chown www-data:www-data -R myproject/

Hope, it helps.

Nation answered 14/8, 2022 at 19:0 Comment(0)
Z
0

My issue was related to Django settings

Django used sqlite3 instead of pgsql because of wrong environment variables values

So my suggestion is to start from /var/log/syslog and try to start gunicorn without nginx

Something like gunicorn --workers=2 'zt.wsgi' -b 0.0.0.0:8000 and then check your website url on 8000 port

Zaller answered 4/12, 2023 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.