Question

Unable to start Gunicorn service for django application

I am having an issue getting my gunicorn service to boot. I am working in digitalocean droplet. I have followed this tutorial and restarted twice: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

I am using the droplet from the marketplace: Django by DigitalOcean

Version 2.2.12

OS Ubuntu 20.04

My gunicorn.service file:

[Unit]
Description=Gunicorn daemon for Django Project
Before=nginx.service
After=network.target

[Service]
WorkingDirectory=/home/django/papayas/
ExecStart=/home/django/papayas/env/bin/gunicorn --bind unix:/home/django/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py config.wsgi:application
User=django
Group=django


[Install]
WantedBy=multi-user.target

the error when restarting gunicorn:


● gunicorn.service - Gunicorn daemon for Django Project
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2021-01-23 11:50:27 UTC; 2s ago
    Process: 16563 ExecStart=/home/django/papayas/env/bin/gunicorn --bind unix:/home/django/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py config.wsgi:application (code=exited, status=1/FAILURE)
   Main PID: 16563 (code=exited, status=1/FAILURE)

DigitalOcean gives you a project that is working and that gunicorn.service is:

[Unit]
Description=Gunicorn daemon for Django Project
Before=nginx.service
After=network.target

[Service]
WorkingDirectory=/home/django/django_project
ExecStart=/usr/bin/gunicorn3 --name=django_project --pythonpath=/home/django/django_project --bind unix:/home/django/gunicorn.socket --config /etc/gunicorn.d/gunicorn.py django_project.wsgi:application
Restart=always
SyslogIdentifier=gunicorn
User=django
Group=django


[Install]
WantedBy=multi-user.target

I have been trying to fix this for days now. I don’t know what to do anymore. please help. I know it has something to do with the gunicorn exec. But I cannot seem to get it right.


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.

Accepted Answer

Managed to get it working by starting a blank Ubuntu droplet and installing everything from scratch.

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