All posts
July 2, 2026·5 min read

How to deploy Django with PostgreSQL for free

A step-by-step guide to deploying a Django app backed by PostgreSQL for free — from a GitHub push to a live HTTPS URL, with environment config and migrations.

Django
PostgreSQL
Tutorial

Django and PostgreSQL are a classic pairing, but hosting them without a credit card used to be hard. This guide shows how to deploy a Django app backed by PostgreSQL for free using Darmi Cloud — from a GitHub push to a live HTTPS URL.

What you'll need

  • A Django project on GitHub with a requirements.txt.
  • A PostgreSQL database. Any provider works — point Django at it with a single DATABASE_URL.
  • A free Darmi Cloud account (sign in with GitHub).

Step 1 — make Django read its config from the environment

In production you never hard-code secrets. Read the database URL, secret key and allowed hosts from environment variables in settings.py:

import os
import dj_database_url

SECRET_KEY = os.environ["SECRET_KEY"]
DEBUG = os.environ.get("DEBUG", "False") == "True"
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")

DATABASES = {
    "default": dj_database_url.config(
        default=os.environ["DATABASE_URL"],
        conn_max_age=600,
    )
}

Add dj-database-url and gunicorn to your requirements.txt if they aren't there yet.

Step 2 — deploy on Darmi Cloud

  1. Sign in with GitHub and click New Project.
  2. Pick your Django repository and branch.
  3. Choose the Django preset. The start command defaults to gunicorn config.wsgi:application --bind 0.0.0.0:8000 — adjust config to your project's package name.
  4. Add environment variables: SECRET_KEY, DATABASE_URL, and ALLOWED_HOSTS (include your Darmi Cloud subdomain).
  5. Click Deploy and watch the live build logs.

Step 3 — run migrations

On the first deploy your database is empty. Run migrations as part of your release flow, or add them to your start command:

python manage.py migrate --noinput && \
gunicorn config.wsgi:application --bind 0.0.0.0:8000

Why free?

Darmi Cloud's free plan deploys one project on an automatic HTTPS subdomain with auto-deploy on push — the kind of free hobby hosting Heroku removed in 2022. When you grow, flat plans keep the bill predictable, or you can self-host the whole platform on your own VPS.

Next steps

  • Add a custom domain (free SSL is automatic).
  • Set DEBUG=False and configure static files with WhiteNoise.
  • Deploying other stacks? See the deploy guides for Node, Laravel, FastAPI and more.

Deploy your app in minutes

Connect GitHub and ship any app — full backend, self-hostable, with flat pricing.

Get started free