Gulp! I had a working site (exhibit.technology), running on a drolet. The site was written in django and used gunicorm and nginx. I need to restart django so I restarted gunicorn (sudo systemctl restart gunicorn) and the web site now return “Server Error 500”. I have restarted nginx, gunicorn, the droplet (from the command line and via a hardware reset from the DO console but this thing is a brick!
Anyone seen such a thing or have suggestions of how to diagnose/fix the problem. Thanks.
A couple of status files…nginx, and then gunicorn
djangoadmin@ubuntu1:~/pyapps/Exhibit/Exhibit.1/Exhibit$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2024-03-17 03:06:49 UTC; 5s ago
Docs: man:nginx(8)
Process: 1453 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 1465 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1454 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1466 (nginx)
Tasks: 2 (limit: 1150)
CGroup: /system.slice/nginx.service
├─1466 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─1468 nginx: worker process
Mar 17 03:06:49 ubuntu1 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mar 17 03:06:49 ubuntu1 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Mar 17 03:06:49 ubuntu1 systemd[1]: Started A high performance web server and a reverse proxy server.
dja
AND…
djangoadmin@ubuntu1:~/pyapps/Exhibit/Exhibit.1/Exhibit$ sudo systemctl status gunicorn
[sudo] password for djangoadmin:
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2024-03-17 02:49:49 UTC; 10min ago
Main PID: 861 (gunicorn)
Tasks: 4 (limit: 1150)
CGroup: /system.slice/gunicorn.service
├─861 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/venv/bin/gunicorn --access-logfile - --error-logfile gunicorn.error --log-level deb
├─964 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/venv/bin/gunicorn --access-logfile - --error-logfile gunicorn.error --log-level deb
├─965 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/venv/bin/gunicorn --access-logfile - --error-logfile gunicorn.error --log-level deb
└─967 /home/djangoadmin/pyapps/venv/bin/python3 /home/djangoadmin/pyapps/venv/bin/gunicorn --access-logfile - --error-logfile gunicorn.error --log-level deb
Mar 17 02:49:49 ubuntu1 systemd[1]: Started gunicorn daemon.
Mar 17 02:55:03 ubuntu1 gunicorn[861]: - - [17/Mar/2024:02:55:03 +0000] "GET / HTTP/1.0" 500 0 "-" "-"
Mar 17 02:58:03 ubuntu1 gunicorn[861]: - - [17/Mar/2024:02:58:03 +0000] "GET / HTTP/1.0" 500 0 "-" "-"
Mar 17 02:58:06 ubuntu1 gunicorn[861]: - - [17/Mar/2024:02:58:06 +0000] "GET / HTTP/1.0" 500 0 "-" "-"
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!
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.
Hey!
The information you’ve provided shows that both Nginx and Gunicorn are active and running, which is good. However, the HTTP 500 errors in your Gunicorn logs indicate that there’s an issue with your Django application. I could suggest checking a few things here:
Check Gunicorn Logs: You can view the Gunicorn logs with more context using commands like
journalctl
. For a more detailed view, try:This command will show you the logs for the Gunicorn service from today. Look for any error messages or stack traces that provide clues about the issue.
Django Application Logs: If you have configured logging in your Django settings, check the designated log files. The location and name of these files depend on your configuration in
settings.py
. If you’re not sure where the logs are, search yoursettings.py
for theLOGGING
configuration.Enable Debug Mode Temporarily (if it’s not a production environment):
Find the
DEBUG
setting and change it toTrue
. Remember, do not do this on a production site.Check Database Connectivity: Use Django’s shell to test database connectivity.
Then, in the shell, try:
If there’s an issue connecting to the database, this will throw an error.
Inspect Nginx Configuration: Ensure Nginx is correctly set up to forward requests to Gunicorn. You can check the configuration with:
This command will test the configuration files for syntax errors.
Let me know how it goes!
Best,
Bobby
Heya @andrewchalk,
Can you check your Nginx logs as well, what do they say? They might also be pointing you to your App but still it’s worth a try to check them as well: