Nginx is not serving the static files that have been collected inside the project directory.

I have seen others face the same issue. Some were solved with user permission, some with a problem in configuration. However, I have double-checked the configuration and user profile and can’t figure out the root of this problem.

My project folder is at the root folder and not inside the home/user directory. Its user permission and the dir structure are as follows:

drwxr-xr-x 4 bsal_dev root       4096 Jan 17 11:44 eiapp
drwxr-xr-x 3 bsal_dev root       4096 Jan 17 14:20 enginfinity
-rwxr-xr-x 1 bsal_dev root        631 Jan 16 04:56
drwxrwxr-x 9 bsal_dev bsal_dev   4096 Jan 17 12:05 static (STATIC_ROOT) 
drwxr-xr-x 8 bsal_dev root       4096 Jan 16 04:56 statics(statics contents of the app)
drwxr-xr-x 3 bsal_dev root       4096 Jan 16 04:56 templates
drwxr-xr-x 2 bsal_dev root       4096 Jan 16 04:56 templatetags
drwxr-xr-x 4 bsal_dev root       4096 Jan 16 04:57 venv

My configuration:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')'

STATIC_URL = '/static/'
    os.path.join(BASE_DIR, 'statics'),



server {

    access_log off;

    location /static/ {
        alias /enginfinity/static

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


Currently, your static files are owned by your bsal_dev, so I think that Nginx might not have the privileges to access those files.

Check what user is your Nginx service running as:

ps aux | grep -i nginx

Then get that user and set the group of the static folder to the Nginx user

chown -R bsal_dev:nginx_user /path/to/your/static_folder

If this still does not work, I would recommend checking your Nginx error log:

tail -100 /var/log/nginx/error.log

Let me know how it goes! Regards, Bobby