Serving Django Channels app w/ Nginx and Daphne throws 403 Forbidden error

Posted March 7, 2019 8.5k views
NginxDjangoUbuntu 16.04

I’m serving my Django Channels app using only Daphne (ASGI) and Nginx as a proxy for my Django app to begin with.

Daphne is running on

However, I am running into a 403 Forbidden error.

2019/03/06 17:45:40 [error] *1 directory index of "/home/user1/app/src/app/" is forbidden

Would someone mind looking over my code as I can’t seem to solve this.

upstream socket {
server $DAPHNE
IPADDRESS$ failtimeout=0;

server {

listen 80;
#listen [::]:80 ipv6only=on;

access_log /etc/nginx/access.log;

root /var/www/html/someroot;

location / {
        #autoindex on;

        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        # try_files $uri =404;

        #proxy_set_header X-Real-IP $remote_addr;
        #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        #proxy_set_header Host $http_host;
        #proxy_set_header X-NginX-Proxy true;
        #proxy_pass http://socket;
        #proxy_redirect off;
        #proxy_http_version 1.1;
        #proxy_set_header Upgrade $http_upgrade;
        #proxy_set_header Connection "upgrade";

        #proxy_redirect off;
        #proxy_set_header   X-Forwarded-Proto $scheme;
        #proxy_cache one;
        #proxy_cache_key sfs$request_uri$scheme;

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/some/fullchain.pem;
# managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/some/privkey.pem; 
# managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

if ($scheme != "https") {
    return 301 https://$host$request_uri;


1 comment

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.

Submit an Answer
3 answers


Someone with more experience in this setup may also want to weigh in, but I wanted to offer my thoughts.

I would check the user that Daphne is running under, and then run something like this:

chown -R user. /home/user1/app/src/app

Replacing “user” with that of the user running Daphne.


Im running the same issue, could you find any solution in this? Thabk you