Question
Nginx not serving static files for Django app! Help!
I’ve wasted 2 entire days without any help on this issue. I followed this guide and have started my application on Digital Ocean. It’s a djago app.
The issue is, it is not loading any static file!
My nano /etc/nginx/sites-available/webapp_name file looks like this:
server {
server_name domainname.com;
access_log off;
location /static/ {
root /opt/bizkeeda;
}
My static files are in folder: /opt/appname/static/
My settings.py file looks like this:
STATIC_URL = '/static/'
STATICFILES_DIR = '/opt/appname/static/'
STATIC_ROOT = '/opt/appname/static/'
I also tried changing STATIC_ROOT to /opt/appname
On checking url of static files on website, it is: www.domain.com:8001/static/js/abc.js
All 404 errors!
What should I do?
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.
×
Look at your Access and Error Logs , in location = /var/log/nginx
Within which the string to look for is = failed (13: Permission denied)
If this exists then its a Permission issue - otherwise follow the usual advise as given in other comments here .