Question

Help with gunicorn.service file setup on Ubuntu 18.04?

Hi there, I have been following the Gunicorn/Django tutorial to set up the Gunicorn service on Ubuntu 18.04 and keep getting errors. The gunicorn.service file contains as set out below:

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

[Service] User=garryjw Group=www-data WorkingDirectory=/home/garryjw/portfolio-project/portfolio ExecStart=/home/garryjw/myvenv/bin/gunicorn
–access-logfile -
–workers 3
–bind unix:/run/gunicorn.sock
portfolio.wsgi:application

[Install] WantedBy=multi-user.target

However, when doing a systemctl status gunicorn check results in the following errors:

● gunicorn.service - gunicorn daemon Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sun 2019-11-17 09:10:07 UTC; 38s ago Process: 18487 ExecStart=/home/garryjw/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock portfolio.wsgi:application (code=exited, status Main PID: 18487 (code=exited, status=203/EXEC)

Nov 17 09:10:07 djangowalaw systemd[1]: Started gunicorn daemon. Nov 17 09:10:07 djangowalaw systemd[18487]: gunicorn.service: Failed to execute command: No such file or directory Nov 17 09:10:07 djangowalaw systemd[18487]: gunicorn.service: Failed at step EXEC spawning /home/garryjw/bin/gunicorn: No such file or directory Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Start request repeated too quickly. Nov 17 09:10:07 djangowalaw systemd[1]: gunicorn.service: Failed with result ‘exit-code’. Nov 17 09:10:07 djangowalaw systemd[1]: Failed to start gunicorn daemon.

Anyone able to help?


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.

Hello,

As far as I can see the service is not starting as the following directory /home/garryjw/bin/ does not exist.

What I could suggest here is to make sure that the directory that you’ve specified in your unit file actually exists:

ls -l /home/garryjw/myvenv/bin/gunicorn

If the directory does not exist, then I would recommend ExecStart=/home/garryjw/myvenv/bin/gunicorn to match the correct path to the gunicorn binary.

Let me know how it goes! Regards, Bobby