How to Run Heroku Locally on a Windows Operating System for a Django Project



Python


In this article, we show how to run heroku locally on a windows operating system for a Django project.

Running heroku locally on a windows operating system is different than running heroku on an operating system such as Linux.

The Procfile that you use in production is not the Procfile that you use locally on a windows operating system.

In the Procfile used in production, gunicorn is specified.

However, the Windows operating system does not understand gunicorn.

When running heroku locally on a Windows operating system, you must create another Procfile.

This procfile should be named, Procfile.windows

This procfile should be placed in the root directory of your project (the same directory that contains the manage.py file).

Inside of this Procfile.windows file, place the following content shown below.



If you want to run your website locally on a different port other than port 8000, then you would substitute 8000 for the port that you want to run your website on.

So this is the complete configuration needed to run windows locally on your PC.

Now go to the heroku command line. To run your website locally, type in the following line below.



After you run this command and there are no errors, you can go to your browser and type in the following line below.



There may be a delay in how quickly your website will show up but if you stay patient, your website will eventually be rendered.

And you now you have heroku locally running on your PC.

The advantage to running heroku locally is that it functions in debug mode. If you were getting some type of error, in a live production website, all you see is server 500 error. If you run heroku locally, you are able to see exactly what caused the server 500 error. An advantage to running heroku locally over running your website locally from your PC is that you may may have all types of environment variables already stored on heroku, so that your local setup on your PC may no longer function correctly. So, once you have your website set up for production and all your secret information, such as your email passwords and amazon web service information is stored on heroku, it's best to run your website locally on heroku.

And this is all that is needed to run heroku locally on a windows operating system.


Related Resources

How to Create a File Uploader with Python in Django

How to Create an Image Uploader with Python in Django



HTML Comment Box is loading comments...