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 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
- Sign in with GitHub and click New Project.
- Pick your Django repository and branch.
- Choose the Django preset. The start command defaults to
gunicorn config.wsgi:application --bind 0.0.0.0:8000— adjustconfigto your project's package name. - Add environment variables:
SECRET_KEY,DATABASE_URL, andALLOWED_HOSTS(include your Darmi Cloud subdomain). - 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:8000Why 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=Falseand 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 freeKeep reading
Vercel pricing explained: when it gets expensive and what to do
An honest breakdown of Vercel's usage-based pricing, where costs tend to climb, when Vercel is still the right choice, and your options when it gets expensive.
Self-hosting your own PaaS: the complete guide
What a Platform-as-a-Service really does, the open-source stack behind it (Docker, Traefik, PostgreSQL, Redis), and how to stand up your own self-hosted PaaS.