I have django application deployed on ubuntu machine, but it doesn't work because of error in gunicorn.service
(it can't find work dir I wrote).My working directory is in /home/ubunut/project
.gunicorn.service
:
[Unit]Description=gunicorn daemonRequires=gunicorn.socketAfter=network.target[Service]User=rootGroup=www-dataWorkingDirectory=/home/ubuntu/project ExecStart=/home/ubuntu/project/env/bin/gunicorn --workers 3 --bind unix:/run/gunicorn.sock project.wsgi:application[Install]WantedBy=multi-user.target
I went into nginx
logs:
2024/07/01 11:04:08 [error] 1906#1906: *23 connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: myipaddress, server: ipaddress, request: "GET /en/ HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/en/", host: "ipaddress"
So i typed the sudo journalctl -u gunicorn.service -f
to see logs in real time:
Jul 01 11:29:17 landingpage (gunicorn)[2472]: gunicorn.service: Changing to the requested working directory failed: No such file or directoryJul 01 11:29:17 landingpage systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CHDIRJul 01 11:29:17 landingpage systemd[1]: gunicorn.service: Failed with result 'exit-code'.Jul 01 11:29:17 landingpage systemd[1]: gunicorn.service: Start request repeated too quickly.Jul 01 11:29:17 landingpage systemd[1]: gunicorn.service: Failed with result 'exit-code'.Jul 01 11:29:17 landingpage systemd[1]: Failed to start gunicorn.service - gunicorn daemon.
I've tried to go to my project root and copy path with pwd
command, checked all the permissions. Still doesn't work. How do i fix gunicorn?