DEV Community

Cover image for How to Deploy Django Website for Free in 2023

Posted on

How to Deploy Django Website for Free in 2023

You created your Django website and now want to see it in action online? Don't worry, this post will explain in detail that How to Deploy Django Website for Free in 2023. Although there are many websites available online to host django website for free, however this post will cover the website I use the most to deploy my django projects regularly.


Knowing how to deploy websites online is one of the crucial skill to learn during your web development journey. Deploying a Django Website is important as it allows users to access the website. Without deployment the website remains confined to the developer's local machine and is of no use to others.


In this tutorial I will share the steps to deploy your django website for free on Railway which is my favorite website to host django websites for free.

What is Railway?

Railway is a cloud-based platform that allows you to set up infrastructure, develop your app using that infrastructure on your local machine, and then deploy your app to the cloud. Railway app makes it extremely easy to host your projects online by importing projects straight from GitHub. In addition, Railway provides fast hosting for users' projects online. Railway provides 500 hours of deployment each month for free in its Starter Plan which can be used to host your personal django projects.

Railway Features

Railway provides various features such as Automagic Builds, Multiple Environments, Deployment Rollbacks and so on.

  1. Automatic Builds: Each time user pushes the code to GitHub, railway will automatically detect the changes and will build the project to deploy it.
  2. Multiple Environments: Users can easily evolve their app overtime with the help of with fork joinable environments.
  3. Deployment Rollbacks: In case the change made to the app has a bug or the user don't like the change, for that case railway supports one-click, instant rollbacks for every change.

How to Deploy Django Website for Free in 2023

Moving forward to host django website for free on Railway, first you need a working django project. In case you do not have any, feel free to fork one from my GitHub repos.

To Deploy Django Website for Free in 2023 follow the steps mentioned below:

  • Firstly install a python library named gunicorn with the following command.
pip install gunicorn
Enter fullscreen mode Exit fullscreen mode
  • In next step, once your project is ready to deploy, create a file named Procfile without any extension in the root directory of the project. Add the following code in the file.
web: gunicorn project.wsgi
Enter fullscreen mode Exit fullscreen mode

Note: Make sure to change project.wsgi to yourprojectname.wsgi

  • Now create a file named requirements.txt which contains all the modules required for the project to run. In the root directory of the file run the following command using terminal.
pip freeze > requirements.txt
Enter fullscreen mode Exit fullscreen mode
  • The next step is to manage the static files during the production. To server static files during production we will use another python package named whitenoise. Install the latest version of the package using the command below.
pip install whitenoise
Enter fullscreen mode Exit fullscreen mode
  • Once the module is installed add the following middleware in the file just below the
    # ...
    # ...
Enter fullscreen mode Exit fullscreen mode
  • Now add the following code in the file.
Enter fullscreen mode Exit fullscreen mode
  • This step will tell the django to serve the staticfiles in the production. Add the following code to the file.
STATIC_URL = 'static/'

    os.path.join(BASE_DIR, "static")

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
Enter fullscreen mode Exit fullscreen mode
  • Once all the above steps are completed, run the command below.
py collectstatic
Enter fullscreen mode Exit fullscreen mode
  • This step finishes all the important steps required to Host Django Website for Free.
  • Now commit all the changes and push the code to GitHub.
  • Visit Railway website and click on Start a New Project.
  • On the next page click in Deploy from GitHub repo and login via GitHub account and give all the necessary permissions required.


  • Once its done, now you can see your project repo in the list, select the project and click on Deploy Now button.
  • After few seconds your Django Project will be hosted on the railway app for free. Now you can access the hosted django website from anywhere.
  • Railway by default gives a long website URL which can be edited by settings section under domain option. Click in the edit icon and add any of your desired domain.



Railway is the quickest way to see your django project in action on the internet. I tried to explain the steps in detail to Deploy Django Website for Free. However, in case of any query feel free to comment your query below.


Top comments (5)

tcollart profile image
Thomas Collart • Edited

Railway isn't a viable solution for free Django hosting anymore.

They changed their plans on August 1st 2023, and with it, the free Starter Plan disappeared.

You'll only have a $5 credit free trial for your first month, then you'll have to pay.

thiagoojack profile image
Thiago Jack

Very nice! Simple and direct. Thank you.

omadbekabdulazizov profile image

[Region: us-west1]


Using Nixpacks


context: bd84fc2def2d4e0571a7e500c2d2ebd2

Nixpacks build failed

╔══════════════════════════════ Nixpacks v1.20.0 ══════════════════════════════╗

║ setup │ python38, gcc ║


║ install │ python -m venv --copies /opt/venv && . /opt/venv/bin/activate ║

║ │ && pip install -r requirements.txt ║


║ start │ ║


Error: No start command could be found deploy procces failed. what's my error

ingarbi profile image
Arby Sayid-Ibrakhimi

until it says to you:"Your Trial is Over"

gamerseo profile image

A very interesting and enlightening post.