Report this

What is the reason for this report?

Update of Static Files Not Working - Nginx

Posted on January 24, 2022

I have Django app and Nginx serving static files. I’ve transferred a static file to my server on droplet and restarted Nginx. I also restarted Gunicorn. I even rebooted my server – and I cannot seem to update the static file on the production-side. It works on my development server just fine. I’ve run python manage.py collectstatic and python manage.py runserver. Still no update of static file. It’s a .png file. Any ideas would be much appreciated.



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!

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.

This comment has been deleted

Heya,

Here’s a few steps you might want to try:

  1. Clear your browser cache: Sometimes, browsers cache static files such as .png images and they may not reflect the recent changes made on the server.
  2. Check file permissions: Make sure the .png file on the server is readable by the user running Nginx and Gunicorn.
  3. Double check the STATIC_URL and STATICFILES_DIRS in your settings.py: Ensure these correctly point to the location where your static files are stored, and where collectstatic is sending them.

If you’re still having issues, you might want to look at your Nginx and Gunicorn configurations. Please note that your static assets should be handled by Nginx and not Gunicorn.

To help you understand better, you can refer to this How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 22.04.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.