heroku-debugging (1).jpg

Common issues and their solutions while deploying to Production

Fixing internal server 500 error, static files not showing and media file issues while deploying django to production server.


It is very common to face issues while deploying your project to any production server be it Heroku, Elastic Beanstalk or any other. We cover different types of issues you can face while deploying and there fixes in this tutorial.

Before you start:

If you are deploying to Heroku or/and serving your media files on AWS S3, i advice you to go through this tutorial and check that you aren't missing something.

Access denied for media in S3:

You might face this error when serving media files in an S3 bucket. This may be because:

1: You didn't deselect the option 'Block all public access' for your S3 bucket. This option is ticked by default and you have to deselect it for public to gain access to your bucket.
So if you haven't deselected that box while creating the bucket, go to your bucket now, under the 'Permissions' tab, you will see the option 'Block all public access', if it is selected, deselect it.

2: You didn't add a CORS configuration to your bucket. Go to your bucket now, under the 'Permissions' tab, you will see another tab 'CORS Configuration', click on that and paste this code in the code box:

<?xml version="1.0" encoding="UTF-8"?>

<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">








Static files not showing:

Static files won't work MOST of the times because you didn't run 'pyhon manage.py collectstatic' in your deployment environment.

Internal Server Error 500:

This is the most annoying error because you don't know whats wrong with your code since the logs don't show much.
There are some errors which don't show when DEBUG=True but show 'Internal Server Error 500' when DEBUG=False

Don't worry though, we have an easy fix. Simply paste this code in to your settings.py file:

   'version': 1,
   'disable_existing_loggers': False,
   'handlers': {
       'console': {
           'class': 'logging.StreamHandler',
   'loggers': {
       'django': {
           'handlers': ['console'],
            'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),


Now just set DEBUG=False in your settings.py file and run the app on local server. If your app isn't working in production, you will most likely see the 'Internal Server 500' error here as well, BUT if you open your terminal, you will also see the logs and will see why are you getting the error.

Once you find the source of the error, its quite easy to fix it.

Learn Django with us

Visit Youtube Channel
Latest articles