Question

Django app not updating after set up with Postgres, Nginx, and Gunicorn on Ubuntu 20.04

I have set up a Django app successfully using a DO droplet. I following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-20-04. After making some changes to my code, I pushed committed (pushed) them to my git repo at github. I then pulled the changes to my server using git pull origin master. I located the changed file and sudo nano it and discovered the code changes are being reflected. I then ran these two commands (sudo systemctl daemon-reload) and (sudo systemctl restart gunicorn).

I even restarted nginx. However no changes are being reflected on my website in production. The changes can be seen on myserver_IP:8000 (sudo ufw allow 8000). The same works when I use gunicorn to load the project’s WSGI module (gunicorn --bind 0.0.0.0:8000 myproject.wsgi). I have been following up on the issue on previous community answers on the same problem but none matches by specific problem.

I later ran this command (journalctl -xe) to determine if my gunicorn restarts successfully. The following is the error log I managed to retrieve:

-- A stop job for unit gunicorn.service has begun execution.
--
-- The job identifier is 22617.
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96466]: [2021-09-05 05:45:29 +0000] [96466] [INFO] Worker exiting (pid: 96466)
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96468]: [2021-09-05 05:45:29 +0000] [96468] [INFO] Worker exiting (pid: 96468)
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96467]: [2021-09-05 05:45:29 +0000] [96467] [INFO] Worker exiting (pid: 96467)
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96459]: [2021-09-05 05:45:29 +0000] [96459] [WARNING] Worker with pid 96466 was terminated due to signal 15
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96459]: [2021-09-05 05:45:29 +0000] [96459] [WARNING] Worker with pid 96467 was terminated due to signal 15
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96459]: [2021-09-05 05:45:29 +0000] [96459] [WARNING] Worker with pid 96468 was terminated due to signal 15
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96459]: [2021-09-05 05:45:29 +0000] [96459] [INFO] Shutting down: Master
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 systemd[1]: gunicorn.service: Succeeded.
-- Subject: Unit succeeded
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit gunicorn.service has successfully entered the 'dead' state.
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 systemd[1]: Stopped gunicorn daemon.
-- Subject: A stop job for unit gunicorn.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit gunicorn.service has finished.
--
-- The job identifier is 22617 and the job result is done.
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 systemd[1]: Started gunicorn daemon.
-- Subject: A start job for unit gunicorn.service has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit gunicorn.service has finished successfully.
--
-- The job identifier is 22617.
Sep 05 05:45:29 ubuntu-s-1vcpu-1gb-lon1-01 sudo[96504]: pam_unix(sudo:session): session closed for user root
Sep 05 05:45:30 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96507]: [2021-09-05 05:45:30 +0000] [96507] [INFO] Starting gunicorn 20.1.0
Sep 05 05:45:30 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96507]: [2021-09-05 05:45:30 +0000] [96507] [INFO] Listening at: unix:/tai/gunicorn.sock (96507)
Sep 05 05:45:30 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96507]: [2021-09-05 05:45:30 +0000] [96507] [INFO] Using worker: sync
Sep 05 05:45:30 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96523]: [2021-09-05 05:45:30 +0000] [96523] [INFO] Booting worker with pid: 96523
Sep 05 05:45:30 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96524]: [2021-09-05 05:45:30 +0000] [96524] [INFO] Booting worker with pid: 96524
Sep 05 05:45:30 ubuntu-s-1vcpu-1gb-lon1-01 gunicorn[96525]: [2021-09-05 05:45:30 +0000] [96525] [INFO] Booting worker with pid: 96525
Sep 05 05:45:37 ubuntu-s-1vcpu-1gb-lon1-01 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=6a:ce:57:14:50:be:fe:00:00:00:01:01:08:00 SRC=107.173.209.244 DST=46.101.44.106 LEN=40 TOS=0x00 PREC=0x00 TTL=2>
Sep 05 05:45:44 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.177.173.24  user=root
Sep 05 05:45:45 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: Failed password for root from 61.177.173.24 port 36579 ssh2
Sep 05 05:45:48 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: Failed password for root from 61.177.173.24 port 36579 ssh2
Sep 05 05:45:50 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: Failed password for root from 61.177.173.24 port 36579 ssh2
Sep 05 05:45:51 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: Received disconnect from 61.177.173.24 port 36579:11:  [preauth]
Sep 05 05:45:51 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: Disconnected from authenticating user root 61.177.173.24 port 36579 [preauth]
Sep 05 05:45:51 ubuntu-s-1vcpu-1gb-lon1-01 sshd[96526]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=61.177.173.24  user=root
Sep 05 05:45:56 ubuntu-s-1vcpu-1gb-lon1-01 sudo[96529]:    caleb : TTY=pts/0 ; PWD=/home/caleb/escort ; USER=root ; COMMAND=/usr/bin/journalctl -xe
Sep 05 05:45:56 ubuntu-s-1vcpu-1gb-lon1-01 sudo[96529]: pam_unix(sudo:session): session opened for user root by root(uid=0)

I have also cleared by browser cache and purged my CDN cache. No changes still on my website. Please any senior to help? This problem is a real headache.


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

Hi there,

If you change Gunicorn socket or service files, first reload the daemon:

sudo systemctl daemon-reload

And then also restart the following two:

sudo systemctl restart gunicorn.socket gunicorn.service

Let me know how it goes! Best, Bobby

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