Question

gunicorn is not running

As i am following through the tutorial of

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-20-04

gunicorn is not running

when i used the command sudo systemctl status gunicorn

my gunicorn.socket file

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

my gunicorn.service file

developer@ubuntu-s-1vcpu-1gb-blr1-01:~$ sudo nano /etc/systemd/system/gunicorn.service

GNU nano 4.8 
                                                /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

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

[Install]
WantedBy=multi-user.target

error comes when i try to check the status of gunicorn by the command

sudo systemctl status gunicorn

Error:

gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2021-06-04 03:53:42 UTC; 48min ago
TriggeredBy: ● gunicorn.socket
   Main PID: 51351 (code=exited, status=1/FAILURE)

Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:     self.stop()
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:   File "/home/developer/myprojectdir/myprojectenv/lib/python3.8/site-packages/gunicorn/arbiter.py>
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:     time.sleep(0.1)
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:   File "/home/developer/myprojectdir/myprojectenv/lib/python3.8/site-packages/gunicorn/arbiter.py>
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:     self.reap_workers()
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:   File "/home/developer/myprojectdir/myprojectenv/lib/python3.8/site-packages/gunicorn/arbiter.py>
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 gunicorn[51351]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Jun 04 03:53:42 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
lines 1-16/16 (END)


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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

A system reboot fixes everything…

i am also facing same isssue

Sep 23 10:57:10 zellaqatar.com systemd[1]: Started gunicorn daemon. Sep 23 10:57:11 zellaqatar.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED Sep 23 10:57:11 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:39 zellaqatar.com systemd[1]: Started gunicorn daemon. Sep 23 10:57:39 zellaqatar.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED Sep 23 10:57:39 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:39 zellaqatar.com systemd[1]: Started gunicorn daemon. Sep 23 10:57:39 zellaqatar.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE Sep 23 10:57:39 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:39 zellaqatar.com systemd[1]: Started gunicorn daemon. Sep 23 10:57:39 zellaqatar.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED Sep 23 10:57:39 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:39 zellaqatar.com systemd[1]: Started gunicorn daemon. Sep 23 10:57:40 zellaqatar.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED Sep 23 10:57:40 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:40 zellaqatar.com systemd[1]: Started gunicorn daemon. Sep 23 10:57:40 zellaqatar.com systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED Sep 23 10:57:40 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:40 zellaqatar.com systemd[1]: gunicorn.service: Start request repeated too quickly. Sep 23 10:57:40 zellaqatar.com systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Sep 23 10:57:40 zellaqatar.com systemd[1]: Failed to start gunicorn daemon.

Hi there,

When checking the Gunicorn application logs, do you get any other errors?

sudo journalctl -u gunicorn

Also I could suggest checking the Gunicorn socket logs by typing the following command:

sudo journalctl -u gunicorn.socket

Feel free to share the logs here as well.

Regards, Bobby