---
title: "Django hosting on Edge | Gunicorn on real VMs"
description: "Run Django on Edge: Gunicorn or Uvicorn on real VMs, django-storages on S3-compatible storage and a global CDN for static and media, with zero egress."
url: https://edge.network/solutions/django
---

For Django

# Django hosting, done properly

Gunicorn or Uvicorn on a real VM, django-storages on an S3-compatible bucket and a CDN across 988 locations. The classic deployment, wired the way you'd do it yourself, only quicker.

[Deploy a VM](/console/access/new?product=compute)[Read the deploy guide](/docs/compute/getting-started)

The setup on this page costs $40.38 a month, with no egress line.

Why Django on Edge

## PaaS convenience at VPS prices

No buildpacks, no dyno maths. A real Linux box for your Python environment, with the storage and delivery already wired in.

-   ### Gunicorn or Uvicorn on real VMs
    
    Run any WSGI or ASGI server (Gunicorn, Uvicorn, Granian or Daphne) on a VM sized to fit. RAM and CPU you can predict.
    
-   ### An S3 storage backend
    
    Point django-storages at Edge Storage and use it for both media and collected static files. It behaves exactly like AWS S3.
    
-   ### Postgres on a private network
    
    Run Postgres on the same VM or its own, joined by a free private network. Or keep your existing managed provider.
    
-   ### Thumbnails without the queue
    
    Skip sorl-thumbnail and its cache table. Request ?width=320&height=320&fit=cover from the CDN and it does the rest.
    
-   ### /static/ and /media/ from the edge
    
    /static/ and /media/ cache in 988 locations. High hit rates on the files people actually load, and no bandwidth bill.
    
-   ### Deploy it from your coding agent
    
    Ask your coding agent to deploy the project to a domain. The agent API provisions the VM, sets up DNS and adds the CDN.
    

Reference architecture

## Gunicorn in front, Postgres on its own VM

Gunicorn on one VM, Postgres on another over a private network, static and media in a bucket, and the CDN in front of both.

-   [Compute](/compute)
    
    Runs Gunicorn (WSGI) or Uvicorn (ASGI) behind Nginx, and Postgres on its own VM.
    
-   [Storage](/storage)
    
    Backs django-storages for both the default and staticfiles storages.
    
-   [CDN](/cdn)
    
    Caches /static/ and /media/ URLs worldwide.
    
-   [Image optimisation](/docs/cdn/image-optimization)
    
    On-the-fly thumbnails, crops and AVIF/WebP from uploaded media.
    
-   [DNS](/dns)
    
    Anycast DNS for the apex, www and admin subdomains.
    
-   [Shield](/shield)
    
    Checks auth and contact forms with one HTTP call from a view.
    
-   [Assist](/assist)
    
    One template include adds answers grounded in your site's content.
    

Deploy

## From startproject to live in five steps

The deployment you already know: a Python VM, Postgres, S3 storage and a release script.

1.  01
    
    ### Create the app and database VMs
    
    The python script installs Python 3.12, pip, Gunicorn and Nginx. The postgresql script sets up PostgreSQL 16. Join both to a private network so the database never faces the internet.
    
    shell
    
    ```
    $ edge compute create --name django --size s-2vcpu-4gb \
        --image ubuntu-24 --region london --script python
    
    $ edge compute create --name db --size s-2vcpu-4gb \
        --image ubuntu-24 --region london --script postgresql \
        --script-param db_name=acme
    ```
    
2.  02
    
    ### Point django-storages at Edge Storage
    
    Use the STORAGES setting (Django 4.2 and later). A custom domain makes static and media URLs go through the CDN.
    
    settings.py
    
    ```
    S3 = "storages.backends.s3.S3Storage"
    STORAGES = {
        "default": {"BACKEND": S3, "OPTIONS": {"location": "media"}},
        "staticfiles": {"BACKEND": S3, "OPTIONS": {"location": "static"}},
    }
    AWS_S3_ENDPOINT_URL = "https://storage.edge.network"
    AWS_S3_REGION_NAME = "us-east-1"
    AWS_STORAGE_BUCKET_NAME = "acme-static"
    AWS_S3_CUSTOM_DOMAIN = "static.acme.io"
    AWS_ACCESS_KEY_ID = os.environ["EDGE_ACCESS_KEY"]
    AWS_SECRET_ACCESS_KEY = os.environ["EDGE_SECRET_KEY"]
    ```
    
3.  03
    
    ### Run Gunicorn under systemd
    
    Nginx from the python script proxies to 127.0.0.1:8000. Swap in Uvicorn workers for ASGI.
    
    /etc/systemd/system/gunicorn.service
    
    ```
    [Unit]
    Description=Gunicorn for acme
    After=network.target
    
    [Service]
    User=www-data
    WorkingDirectory=/srv/acme
    ExecStart=/srv/acme/.venv/bin/gunicorn acme.wsgi:application \
        --workers 4 --bind 127.0.0.1:8000
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    ```
    
4.  04
    
    ### Ship a release
    
    Pull, install, migrate, collect, restart. Wrap it in a CI job once it works by hand.
    
    shell
    
    ```
    $ git pull && .venv/bin/pip install -r requirements.txt
    $ .venv/bin/python manage.py migrate --noinput
    $ .venv/bin/python manage.py collectstatic --noinput
    $ sudo systemctl restart gunicorn
    ```
    
5.  05
    
    ### Front it with the CDN
    
    One deployment, two hostnames: the app goes to the VM, static and media come from the bucket.
    
    shell
    
    ```
    $ edge cdn create --name acme
    $ edge cdn domains add cdn-61f0a8 \
        --domain app.acme.io --origin https://<vm-ip>
    $ edge cdn domains add cdn-61f0a8 --domain static.acme.io \
        --origin-type storage --storage-bucket acme-static --jit-image
    ```
    

Prefer to hand it off? [Give the job to your AI agent](/solutions/agentic-development) or [have our engineers do it](/solutions/expert-services).

What it costs

## Two VMs, one bucket, no dyno maths

An app server and a database server, each with its own CPU and memory. Static and media ride the CDN for pennies.

-   The private network between VMs is free
-   No egress fees on static files or media
-   Thumbnails included with the CDN

[See compute pricing](/compute/pricing)

Estimated monthly bill on Edge

Production app, 4.5M requests a month, 65 GB of media

USD

-   App VM$19.24Standard VM, 2 vCPU, 4 GiB, Gunicorn + Nginx
-   Database VM$19.24Standard VM, 2 vCPU, 4 GiB, PostgreSQL 16
-   CDN$1.004.5M requests: first 500k free, 4M × $0.25 per million
-   Storage$0.9065 GB of static and media: first 5 GB free, 60 GB × $0.015
-   DNS$0.00Apex, www and admin records
-   Egress$0.00

Total$40.38

FAQ

## WSGI, Postgres and the admin

Something else? [Ask an engineer](/contact).

WSGI or ASGI?

Either. Gunicorn for classic Django, Uvicorn or Daphne for ASGI and Channels. Both run as ordinary Python processes on an Edge VM behind Nginx or Caddy.

Where should Postgres run?

For small and medium loads, on the same VM. For larger ones, give it its own VM on a private network (free, same region) to keep latency low. Or point Django at your existing managed Postgres.

How do I deploy?

The usual: git pull, pip install, manage.py migrate, manage.py collectstatic, restart Gunicorn. Put those four commands in a CI job or a small deploy script.

Does the admin work behind the CDN?

Yes. Responses that set cookies or send Cache-Control: private are never cached, so the admin and logged-in pages go straight to Gunicorn. Add your domain to CSRF\_TRUSTED\_ORIGINS and set SECURE\_PROXY\_SSL\_HEADER.

How does this compare with Heroku?

You get real CPU and disk, full control of the Python environment, and a bill that doesn't scale with dynos or add-ons. The trade-off is one bootstrap script, and the python library script is most of it.

Drop-in services

## One view check, one template include

-   [
    
    Edge ShieldBot protection`POST /siteverify → score: 94`
    
    Validate the humanity score in a form view with one requests call. No CAPTCHA widget in your templates.
    
    Free forever, with unlimited widgets. No puzzles for visitors.Explore
    
    ](/shield)
-   [
    
    Edge AssistAI answers`<script src="…/assist.js">`
    
    One template include gives every page an answer box grounded in your content.
    
    Free tier: 250 answered questions a monthExplore
    
    ](/assist)

Related stacks

## Sibling frameworks, and the database Django prefers

[All 38 stacks](/solutions/stacks)

-   [RailsClassic VPS workflow, modern network](/solutions/rails)
-   [LaravelProduction VMs, S3 storage and CDN](/solutions/laravel)
-   [Node.jsExpress, Fastify or Hono on your own runtime](/solutions/nodejs)
-   [PostgreSQLSelf-hosted Postgres on dedicated NVMe](/solutions/postgresql)

## Put your Django project behind the edge

Bring an existing project or start with django-admin startproject. We'll help you size the VMs.

[Deploy a VM](/console/access/new?product=compute)[Talk to an engineer](/contact)

Billed hourly from a prepaid balance. Egress is free on every product.
