[Fixed]-Elastic beanstalk – app is returning 403 not found error for static files

1πŸ‘

βœ…

In django, you can group all the static files from different directories, which you specify in the STATICFILES_DIRS variable.

There is a command called python manage.py collectstatic, that does the above job of copying all the static files in STATICFILES_DIRS, and also the static files related to the admin panel, and in this case, your Rest Framework related static files. All the static files are copied to a directory which you would have mentioned as STATIC_ROOT in your django settings file.

Now 2 things have to be made sure by you:

1) You run the python manage.py collectstatic command
2) Do a chmod -R 777 /path/to/static_root

You get 403 because the web server cannot access your static file, since it is denied the permission to read the file. Doing a chmod 777 gives the permission to read (and write and execute ) the static file, which should clear your problem.

Leave a comment