Friday, January 23, 2026
HomeLanguagesConfiguring Django Apps for Heroku

Configuring Django Apps for Heroku

In this article, we will learn how to configure a Django app for Heroku step-by-step. 

Heroku is a cloud-based application deployment and management service which supports several programming languages such as Ruby, Java, Node.js, Scala, Clojure, Python, PHP, and Go. It requires a Procfile, this file is used to declare your entry points and application’s process. 

Stepwise Implementation

Step 1: Create Environment: 

Create a virtual environment in your Django project folder. Run the following command:

python -m venv .venv

Step 2: Virtual Environment: 

Enter the created environment with the help of the below command: 

source .venv/bin/activate

 

Step 3: Install Dependencies:

 Install all the packages and libraries required to run your web application along with gunicorn.

Note: You might require to install more dependencies besides Django if your application is using any. For example djangorestframework

pip install django gunicorn

 

Step 4: Requirements file: 

Create a “requirements.txt” file so that Heroku knows all the dependencies it needs to run our application.

pip freeze > requirements.txt

 

Step 5: Procfile: 

Create a file named “Procfile” within your root directory and write the following:

web: gunicorn [project-name].wsgi --log-file -

 

Step 6: Runtime file: 

Create a new file named “runtime.txt” within your root directory,  It tells Heroku what version of Python your application is using. 
You can check your version by following the command “python –version” and pasting it into the runtime.txt.

python-3.x.xx

 

Step 7: Debug Settings: 

Navigate yourself to the settings.py file under projects and set debug value False (Default = True).

Note: Never deploy a site into production with DEBUG turned on.

DEBUG = False

 

Step 8: Allowed Host: 

Add your Heroku app URL and localhost in the Allowed Host list which is within your settings.py file.

You can also  allow all apps from Heroku by omitting the app name like this:

ALLOWED_HOSTS = [‘.herokuapp.com’] and You can also use [‘*’] to allow all hosts.

ALLOWED_HOSTS = ['127.0.0.1', '<HerokuAppName>.herokuapp.com']

 

Now your Django application has been configured to be deployed on Heroku. So you can go ahead and deploy.

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS