NGinx + Gunicorn + Django setup

I followed this tutorial and I’ve checked everything a few times over, but I get a “Server Error (500)” when I try to access the server via the ip. If I look at the error log, nothing is there. The access log, however does show my attempts.

In sites-available and sites-enabled I have the config file

server {
       listen 80;
       server_name <IP ADDRESS>;
       location = /favicon.ico {access_log off;log_not_found off;}

       location /static/ {
         root /home/deploy/sax-website/sax;
       location /media/ {
         root /home/deploy/sax-website/sax;

       location / {
         include proxy_params;
         proxy_pass http://unix:/home/deploy/sax-website/sax/sax.sock;

home/deploy/sax-website/sax is the directory with the file and it also contains the sax.sock file created during gunicorn setup.

home/deploy/sax-website/sax contains a subfolder for fonts, images, scripts and a single css file.

home/deploy/sax-website/sax/media the media added to db via the admin panel.

I tried removing the link to sites-available/default from sites-enabled but that didn’t help.

Can anybody suggest some steps for debugging? Is there a way to gunicorn + django without nginx so I can isolate the issue? Any ideas why there’s nothing in /var/log/nginx/error.log?

Any help would be greatly appreciated. I’m also open to other approaches to deployment if there is a better or easier way.


Submit an 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.

Hi @nlhaines:

There are many detailed tutorials on DigitalOcean on this topic. They have all been carefully checked by DigitalOcean editor team. You can follow the tutorial that corresponds to your operating system, for example, How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 20.04.