# Server 403 error when serving static files with Nginx

**URL:** <https://forum.djangoproject.com/t/server-403-error-when-serving-static-files-with-nginx/9430>\
**Category:** Deployment\
**Created:** [August 27, 2021, 11:24pm UTC](https://forum.djangoproject.com/t/server-403-error-when-serving-static-files-with-nginx/9430 "2021-08-27T23:24:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scmj](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/scmj/32/5636_2.png) [@scmj](https://forum.djangoproject.com/u/scmj)\
**Post date:** [August 27, 2021, 11:24pm UTC](https://forum.djangoproject.com/t/server-403-error-when-serving-static-files-with-nginx/9430/1 "2021-08-27T23:24:17Z")

</div>

Hi there,

During deployment of Django (Gunicorn+Nginx) I have encountered the following issue:

1. Site loads correctly, and debug default page comes on. The terminal annouces the first two errors:

```auto
(django_env) user@mysite.com:$ Not Found: /error/403.html
Not Found: /favicon.ico

```

1. When navigating to [mysite.com/admin](http://mysite.com/admin) none of the static files are loading, and multiple “Not Found: /error/403.html” are returned on the terminal.

2. I have checked nginx error log, finding no server 403 errors (just a warning relating ssl stapling):

```auto
2021/08/28 00:08:00 [warn] 4549#4549: "ssl_stapling" ignored, issuer certificate not found...

```

1. I have checked the permissions on my static folder (/home/user/myproject/static) and are set to 755:  
 ![Captura de pantalla 2021-08-28 011244](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/6/6c4b6064a008a677ab2dd4627222d958137605ff.png)

This is what my settings.py static section looks like:

```auto
STATIC_URL = '/static/'
STATIC_ROOT = "/home/user/myproject/static"

```

This is what my nginx myproject.conf file looks like

```auto
server {
        listen xxxxxxxxxx:443 ssl;
        server_name site.com;
        ssl_certificate /usr/local/xxxxxx.crt;
        ssl_certificate_key /usr/local/xxxxx.key;
        #access_log /var/log/ngin/xxxxxxxxx.log main;
       
       location /static/ {
            alias /home/user/myproject/static;
        }

        location / {
                proxy_pass http://xxxxxxxx:8000/;
        }
}

```

User set in nginx.conf is ‘nginx’ and the rest of relevant configurations go as follow:

```auto
# Server globals
    user nginx;
################
# Error pages
    error_page 403 /error/403.html;
    error_page 404 /error/404.html;
    error_page 502 503 504 /error/50x.html;
###############
# Wildcard include
    include /etc/nginx/sites-enabled/myproject;

```

I am certain I might have missed several things here (maybe I should pay attention to the whole permission hierarchy, setting permissions elsewhere, adequately configure nginx…), forgive my limited experience.

Thank you in advance for your help!

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 28, 2021, 12:42am UTC](https://forum.djangoproject.com/t/server-403-error-when-serving-static-files-with-nginx/9430/2 "2021-08-28T00:42:55Z")

</div>

The issue _could_ be caused by a lack of permissions higher up. Check the permissions at /home, /home/user, and /home/user/myproject.

But, I think you’d be better off (easier and with fewer chances of side effects) by moving STATIC\_ROOT to something like /var/www/html/static.

If you need more details, check the nginx logs - don’t rely solely on the console output. You can also run nginx with more detailed logging.
