Cannot get NGINX, UWSGI, DJANGO working on port 80

I'm following this tutorial to setup Nginx --> uwsgi --> Django. It all works fine when the Nginx server block is set to listen on port 8000 but I cannot get it to work when the port is set to 80. I eventually get site unreachable.

My sites-enabled/conf file is:

# tracking_nginx.conf

# the upstream component nginx needs to connect to
upstream django {
    server unix:///home/dconran/django3/tracking/mainsite.sock; # for a file socket
    # server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

# configuration of the server
server {
    # the port your site will be served on
    listen      8000;   #  <--- works
    # listen      80;   #  <---  doesn't work

    # the domain name it will serve for
    server_name corunna.com www.corunna.com; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    # location /media  {
    #     alias /path/to/your/mysite/media;  # your Django project's media files - amend as required
    # }

    location /static {
        alias /home/dconran/django3/tracking/tracker/static; # your Django project's static files - amend as required
    }

    # Finally, send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/dconran/django3/tracking/uwsgi_params; # the uwsgi_params file you installed
    }
}

When I try uwsgi --http :8000 --module mainsite.wsgi that also works but uwsgi --http :80 --module mainsite.wsgi gives the following error:

*** Starting uWSGI 2.0.29 (64bit) on [Mon Apr 14 15:58:21 2025] ***
compiled with version: 13.3.0 on 12 April 2025 17:42:47
os: Linux-6.8.0-52-generic #53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025
nodename: ubuntu
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home/dconran/django3/tracking
detected binary path: /home/dconran/django3/venv/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7283
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Permission denied [core/socket.c line 769]

I don't know what Permission is being denied as my mainsite.wsgi app is set to -rw-rw-r-- 1 dconran dconran 393 Mar 20 22:15 wsgi.py and dconran has been added to the www-data group.

The socket permission is set to srw-rw-rw- 1 dconran dconran 0 Apr 14 15:44 mainsite.sock

What am I doing wrong and how can I fix it?

Back to Top