[Fixed]-Django – Media upload [Errno 13] Permission denied


The process that is running your Python interpreter doesn’t have permission to write into the media directory. You’ll need to either chgrp or chown the media directory to the same group as your Python process, and ensure you have at least g+rwx on directories and g+rw on files.


I was getting the same error and fix it by changing:

MEDIA_ROOT = '/media/'


MEDIA_ROOT = 'media/'

Under settings.py.


Make sure you have done following

Your settings.py

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

Also set permission to media directory

chgrp -R www-data /path/to/media/
chmod -R g+w  /path/to/media/


For me, I forgot to add: MEDIA_ROOT = os.path.join(BASE_DIR,’media’) to my settings.py file on my production server.


Thanks to https://stackoverflow.com/users/10949995/clement-tong for the inspiration. I experienced the same error in a production environment and I had to change settings.py file to include a preceding forward slash:

MEDIA_ROOT = os.path.join(BASE_DIR, "/media")


I was getting the same error and fix it by doing the following in setting.py file of the project:

MEDIA_ROOT = '/media/'


MEDIA_ROOT = 'media/'

Leave a comment