'gunicorn.service: Failed to determine user credentials: No such process - django, gunicorn, and nginx
When I run sudo systemctl status gunicorn, I get the following error:
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2022-02-08 07:29:18 UTC; 17min ago
Main PID: 21841 (code=exited, status=217/USER)
Feb 08 07:29:18 ip-172-31-37-113 systemd[1]: Started gunicorn daemon.
Feb 08 07:29:18 ip-172-31-37-113 systemd[21841]: gunicorn.service: Failed to determine user credentials: No such process
Feb 08 07:29:18 ip-172-31-37-113 systemd[21841]: gunicorn.service: Failed at step USER spawning /home/ubuntu/bookclub/venv/bin/gun
Feb 08 07:29:18 ip-172-31-37-113 systemd[1]: gunicorn.service: Main process exited, code=exited, status=217/USER
Feb 08 07:29:18 ip-172-31-37-113 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
I'm following this tutorial from DigitalOcean to get my Django website onto my EC2 instance. I'm using Nginx and Gunicorn with Django to accomplish this.
This is my gunicorn.service file at /etc/systemd/system/gunicorn.service:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/ubuntu/bookclub
ExecStart=/home/ubuntu/bookclub/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/bookclub/books.sock books.wsgi:application
[Install]
WantedBy=multi-user.target
I checked for books.sock in my project folder with ls and I saw that books.sock does not exist.
Edit
I changed User in my Gunicorn service file from sammy (which didn't exist) to ubuntu (which is the only one that exists on the server).
So my gunicorn.service looks like this now:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/ubuntu/bookclub
ExecStart=/home/ubuntu/bookclub/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/bookclub/books.sock books.wsgi:application
[Install]
WantedBy=multi-user.target
But I get another error:
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2022-02-08 09:23:41 UTC; 19s ago
Main PID: 22533 (code=exited, status=203/EXEC)
Feb 08 09:23:41 ip-172-31-37-113 systemd[1]: Started gunicorn daemon.
Feb 08 09:23:41 ip-172-31-37-113 systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Feb 08 09:23:41 ip-172-31-37-113 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
