Skip to content

Offer: your first month of web hosting is free on monthly plans. Order by 7 Jan. See plans

HostEthical
All guides

Guides 17 min read ·

How to Deploy a Django Project in India: Web Hosting or a VPS with Nginx and Gunicorn

Deploy a Django app in 2026: free tiers on Render, Vercel and PythonAnywhere, small apps on web hosting, and a full VPS setup with Gunicorn, Nginx and Postgres.

To deploy a Django project you run it under a WSGI server such as Gunicorn, put Nginx in front for HTTPS and static files, and connect a real database such as PostgreSQL. In India you can do that on web hosting that runs Python apps (fine for a small site), on a free platform such as Render, Vercel or PythonAnywhere (fine for demos, but apps sleep, expire or run far away), or on a Linux VPS. A production Django app with PostgreSQL, Celery, Redis or user uploads belongs on a VPS.

This guide uses Django 6.1 (6.1.3, the current release), Gunicorn 27, PostgreSQL 16 and Nginx on Ubuntu 24.04 LTS, as of November 2026. The same steps work on Django 5.2 LTS. For JavaScript back ends, see Node.js hosting in India.

Where can you deploy a Django app in India?

OptionHow Django runsCatches (checked November 2026)
Web hosting with Python apps (such as ours)Gunicorn or Uvicorn, started and restarted for youMySQL rather than PostgreSQL, no root, Redis or Celery, static files served by WhiteNoise. Details below
Render, free web serviceA container that spins down when idleSpins down after 15 minutes without inbound traffic and takes about a minute to wake. Free Postgres expires after 30 days, no persistent disk for uploads, SMTP ports blocked
Railway, Free planA containerUS$1 of usage a month, 0.5 GB RAM per service, sleeps after 5 to 10 minutes without outbound traffic
Vercel, Hobby planThe whole app becomes one Vercel FunctionDetects Django and runs collectstatic for you, but 300 seconds at most per request, 4.5 MB request bodies, no database included, Washington, D.C. region by default
PythonAnywhere, freeOne web app at yourname.pythonanywhere.comNo custom domain, no MySQL for new free accounts, outbound internet limited to an allowlist, and the app expires after a month unless you extend it
Linux VPSGunicorn and Nginx under systemd, on all the timeYou install, secure and update it yourself

Free tiers suit learning and portfolio projects. Always-on plans cost dollars: on Render, a 512 MB Starter instance is US$7 a month and the smallest paid Postgres is US$6 plus storage, so at least US$13 a month (about ₹1,205 at ₹92.7 to the dollar), charged to a card. Railway's Hobby plan is US$5 a month including US$5 of usage, and PythonAnywhere's Developer plan is US$10. Neither Render nor Railway has an India region; the nearest is Singapore. Our guide to Vercel alternatives in India compares the paid options.

Which Django version should you deploy in November 2026?

From Django's download page, Python support table and database notes for 6.1 and 5.2:

VersionPythonDatabasesSecurity fixes until
Django 6.1 (current)3.12, 3.13, 3.14, 3.15PostgreSQL 15+, MySQL 8.4+, MariaDB 10.11+December 2027
Django 5.2 LTS3.10 to 3.14PostgreSQL 14+, MySQL 8.0.11+, MariaDB 10.5+April 2028
Django 6.03.12, 3.13, 3.14PostgreSQL 14+, MySQL 8.0.11+, MariaDB 10.6+April 2027 (bug fixes ended August 2026)

Start new projects on 6.1, or on 5.2 LTS if a package you depend on hasn't caught up; the next LTS, 6.2, is due in April 2027. Ubuntu 24.04 ships Python 3.12.3 and PostgreSQL 16, which suit both. Its system Python is marked externally managed (PEP 668), so pip refuses to install outside a virtual environment.

How to deploy Django with Nginx and Gunicorn on Ubuntu 24.04

These steps take a project from Git to https://example.com. They assume manage.py sits at the top of the repository and the project package (the folder with settings.py and wsgi.py) is called mysite. First point A records for example.com and www at the server's IP (see DNS records explained).

1. Create a non-root user and install the packages

Never run Django as root. If you followed how to set up a VPS, you already have a sudo user and SSH keys. These examples use a user called deploy:

sudo adduser deploy
sudo usermod -aG sudo deploy
su - deploy
sudo apt update
sudo apt install -y python3-venv python3-dev build-essential libpq-dev postgresql nginx git

python3-dev, build-essential and libpq-dev let pip compile the PostgreSQL driver.

2. Create the PostgreSQL user and database

openssl rand -hex 24                      # prints a password you can use below
sudo -u postgres createuser --pwprompt mysite
sudo -u postgres createdb --owner mysite mysite

Make mysite the database owner. Since PostgreSQL 15, ordinary users can't create tables in the public schema of a database they don't own, which is the usual cause of "permission denied for schema public" on the first migrate. PostgreSQL listens only on localhost by default, so keep port 5432 closed.

3. Clone the project and create a virtual environment

git clone https://github.com/your-name/mysite.git ~/mysite
cd ~/mysite
python3 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt

# requirements.txt needs at least:
Django>=6.1,<6.2
gunicorn
psycopg[c]

Django recommends psycopg 3 for PostgreSQL. psycopg's documentation calls the local build, psycopg[c], the preferred install for a production site, because it uses the system's libpq and picks up its security updates. psycopg[binary] needs no compiler and is fine to start with. For a private repository, use a read-only deploy key.

4. Keep secrets in environment variables

Django's deployment checklist says the secret key must be a large random value kept out of source control, and that you must never enable DEBUG in production. Read both, and everything else that differs per server, from the environment:

# mysite/settings.py: the production-relevant parts
import os
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
DEBUG = os.environ.get("DJANGO_DEBUG") == "1"
ALLOWED_HOSTS = os.environ["DJANGO_ALLOWED_HOSTS"].split(",")
CSRF_TRUSTED_ORIGINS = [f"https://{host}" for host in ALLOWED_HOSTS]

# Only because our own Nginx sets X-Forwarded-Proto on every request (step 7)
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
SESSION_COOKIE_SECURE = not DEBUG
CSRF_COOKIE_SECURE = not DEBUG

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": os.environ["DB_NAME"],
        "USER": os.environ["DB_USER"],
        "PASSWORD": os.environ["DB_PASSWORD"],
        "HOST": os.environ.get("DB_HOST", "127.0.0.1"),
        "PORT": os.environ.get("DB_PORT", "5432"),
    }
}

STATIC_URL = "static/"
STATIC_ROOT = os.environ.get("DJANGO_STATIC_ROOT", BASE_DIR / "staticfiles")
MEDIA_URL = "media/"
MEDIA_ROOT = os.environ.get("DJANGO_MEDIA_ROOT", BASE_DIR / "media")

Django's documentation says to set SECURE_PROXY_SSL_HEADER only when you control the proxy and it discards any X-Forwarded-Proto header the visitor sends and sets its own, which the proxy_set_header line in step 7 does. Static and media files go under /var/www because Ubuntu has made home directories private (mode 750) since 21.04, so Nginx's www-data user can't read files inside /home/deploy. Now create the folders and the .env file:

sudo mkdir -p /var/www/mysite/static /var/www/mysite/media
sudo chown -R deploy:deploy /var/www/mysite
python3 -c "import secrets; print(secrets.token_urlsafe(50))"   # your secret key
nano ~/mysite/.env
chmod 600 ~/mysite/.env

# example contents of .env (no quotes, no spaces around =)
DJANGO_SECRET_KEY=paste-the-generated-key
DJANGO_ALLOWED_HOSTS=example.com,www.example.com
DJANGO_STATIC_ROOT=/var/www/mysite/static
DJANGO_MEDIA_ROOT=/var/www/mysite/media
DB_NAME=mysite
DB_USER=mysite
DB_PASSWORD=the-password-from-step-2

Add .env to .gitignore. The generated key uses only letters, digits, - and _, so systemd and the shell both read it safely.

5. Migrate, collect static files and run the deploy check

cd ~/mysite
set -a; . ./.env; set +a          # loads .env into this shell session
.venv/bin/python manage.py migrate
.venv/bin/python manage.py collectstatic --noinput
.venv/bin/python manage.py createsuperuser
.venv/bin/python manage.py check --deploy

collectstatic copies every app's static files, the admin's included, into STATIC_ROOT for Nginx. check --deploy runs Django's security checks. Expect warnings about SECURE_SSL_REDIRECT, which certbot's redirect in step 8 handles, and SECURE_HSTS_SECONDS: add HSTS once HTTPS works on every hostname you use, because browsers remember it.

6. Run Gunicorn under systemd

This follows the pattern in Gunicorn's deployment docs: systemd owns a Unix socket and starts Gunicorn when the first request arrives, including the first one after a reboot. Create /etc/systemd/system/gunicorn.socket:

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock
SocketUser=www-data
SocketGroup=www-data
SocketMode=0660

[Install]
WantedBy=sockets.target

Then /etc/systemd/system/gunicorn.service:

[Unit]
Description=gunicorn daemon for mysite
Requires=gunicorn.socket
After=network.target

[Service]
Type=notify
NotifyAccess=main
User=deploy
Group=deploy
WorkingDirectory=/home/deploy/mysite
EnvironmentFile=/home/deploy/mysite/.env
ExecStart=/home/deploy/mysite/.venv/bin/gunicorn mysite.wsgi:application --workers 9 --access-logfile -
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now gunicorn.socket
sudo -u www-data curl -sI --unix-socket /run/gunicorn.sock -H "Host: example.com" http://localhost/
sudo journalctl -u gunicorn -f      # live logs; Ctrl+C to stop watching

A 200 or 302 reply means Django answered (so does a 404 if you have no page at /). Gunicorn's design notes suggest starting with (2 × CPU cores) + 1 workers, so 9 on VPS Starter's 4 vCPU. Each worker is a separate process with its own memory, so check systemctl status gunicorn after a day of real traffic and lower the number if RAM is tight.

7. Configure Nginx to serve /static/ and /media/

Create /etc/nginx/sites-available/mysite:

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;

    client_max_body_size 10M;      # the default is 1 MB; raise it for file uploads

    location /static/ {
        alias /var/www/mysite/static/;
    }

    location /media/ {
        alias /var/www/mysite/media/;
    }

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Nginx now sends CSS, JavaScript and uploads straight from disk without touching Python, and never runs them, which matters because Django's checklist calls uploads untrusted. Uploads bigger than client_max_body_size get a 413 error. The X-Forwarded-Proto line is the header SECURE_PROXY_SSL_HEADER relies on, so don't drop it.

8. Turn on HTTPS with Let's Encrypt

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
sudo certbot renew --dry-run

Certbot gets the certificate, edits your server block and, by default, redirects HTTP to HTTPS. Let's Encrypt certificates last 90 days today, and the default drops to 64 days in February 2027 and 45 days in 2028. Ubuntu's certbot package installs a systemd timer that renews them automatically; the dry run confirms renewal works. See what is an SSL certificate for the background.

9. Open only ports 22, 80 and 443

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

Allow SSH before enabling the firewall, or you'll lock yourself out. If you later run PostgreSQL or Redis in containers, read our Docker on a VPS guide first: published Docker ports bypass ufw.

Give your Django app a server that never sleeps. VPS Starter has 4 vCPU, 8 GB RAM, full root and a dedicated IPv4 in Mumbai or Germany, from ₹860 a month, or about ₹774.17 a month when billed yearly. See VPS plans →

Do you need Celery and Redis for Django?

Only when work shouldn't happen while a visitor waits: bulk email, PDF reports, image resizing, slow outside APIs, or scheduled jobs with Celery beat. Django 6.0 added a Tasks framework for defining and queuing background work, but the release notes say Django "does not provide a worker mechanism to run tasks", so something else still has to run them. Celery 5.7 with Redis as the broker is the usual choice. Workers and Redis are processes that run all the time, so on your own server they need a VPS; web hosting can't run them.

sudo apt install -y redis-server
~/mysite/.venv/bin/pip install "celery[redis]"      # and add celery[redis] to requirements.txt
echo "CELERY_BROKER_URL=redis://127.0.0.1:6379/0" >> ~/mysite/.env
# in settings.py:  CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL")

Add mysite/celery.py as shown in Celery's First steps with Django; its example loads every CELERY_ setting from your Django settings. Then run the worker as a second service, /etc/systemd/system/celery.service:

[Unit]
Description=Celery worker for mysite
After=network.target redis-server.service

[Service]
User=deploy
Group=deploy
WorkingDirectory=/home/deploy/mysite
EnvironmentFile=/home/deploy/mysite/.env
ExecStart=/home/deploy/mysite/.venv/bin/celery -A mysite worker -l INFO
Restart=always

[Install]
WantedBy=multi-user.target

Start it with sudo systemctl enable --now celery. Keep Redis on localhost and never open port 6379.

How do you redeploy a Django app after a change?

Save this as ~/mysite/deploy.sh, run chmod +x deploy.sh, and run ./deploy.sh after each push:

#!/usr/bin/env bash
set -e
cd /home/deploy/mysite
git pull --ff-only
.venv/bin/pip install -r requirements.txt
set -a; . ./.env; set +a
.venv/bin/python manage.py migrate --noinput
.venv/bin/python manage.py collectstatic --noinput
sudo systemctl restart gunicorn
# sudo systemctl restart celery    # if you run a worker

Because systemd holds the socket, requests that arrive during the restart wait instead of failing. Restart after editing .env too. If you'd rather deploy from a dashboard, Coolify and Dokploy run on your own VPS; see Coolify vs Dokploy.

How do you back up a Django PostgreSQL database?

pg_dump makes a consistent backup while the site is running and doesn't block readers or writers. Its custom format (-Fc) is compressed and restores with pg_restore. Store the password in ~/.pgpass so cron can run it:

mkdir -p ~/backups
echo "127.0.0.1:5432:mysite:mysite:the-db-password" > ~/.pgpass
chmod 600 ~/.pgpass             # PostgreSQL ignores the file otherwise
pg_dump -h 127.0.0.1 -U mysite -Fc -f ~/backups/mysite-$(date +%F).dump mysite

# crontab -e: every night at 02:30, keeping 14 days
30 2 * * * pg_dump -h 127.0.0.1 -U mysite -Fc -f "$HOME/backups/mysite-$(date +\%F).dump" mysite && find "$HOME/backups" -name "mysite-*.dump" -mtime +14 -delete

# restore into the existing database
pg_restore -h 127.0.0.1 -U mysite -d mysite --clean --if-exists ~/backups/mysite-2026-11-23.dump

Back up uploads too (tar -czf ~/backups/media-$(date +%F).tar.gz -C /var/www/mysite media), then copy everything off the server with rsync or to object storage: a backup on the same disk dies with the server.

Can you deploy Django on HostEthical web hosting?

Yes, for a small app. Our web hosting can run one Node.js or Python app per website: Python 3.12 under Gunicorn, with Uvicorn workers for ASGI apps, kept running and restarted if it crashes. Compared with the VPS, you get MySQL instead of PostgreSQL, the host's web server instead of your own Nginx, no root, no Redis or Celery, and blocked SMTP. Here's how to adapt the project:

  1. Choose Django 5.2 LTS. Django 6.1 runs on Python 3.12 but needs MySQL 8.4 or MariaDB 10.11 or newer (phpMyAdmin's home page shows your server's version). Django 5.2 accepts MySQL 8.0.11 and MariaDB 10.5 upwards, gets security fixes until April 2028, and is supported by the current WhiteNoise release, 6.12.0, whose Django 6.1 support isn't released yet.
  2. Serve static files with WhiteNoise. Your app receives every request, /static/ included, so follow WhiteNoise's Django guide. WhiteNoise doesn't serve user uploads: store those in object storage through django-storages, or use the VPS.
  3. Pick a MySQL driver. Django officially supports mysqlclient (its recommended choice) and MySQL Connector/Python. mysqlclient has no Linux wheels on PyPI, so it compiles during install and needs MySQL client headers. If that fails, PyMySQL is a pure-Python stand-in: Django's docs don't mention it, but it reports a mysqlclient-compatible version, so Django accepts it once you add import pymysql and pymysql.install_as_MySQLdb() at the top of settings.py.
  4. Send email through an API. Outgoing SMTP ports are blocked on our hosting servers to stop spam (here's why), so use django-anymail with Brevo, SendGrid, Mailgun, Postmark, Resend or Amazon SES. Django 6.1 adds a MAILERS setting that will replace EMAIL_BACKEND, which now gives deprecation warnings; Anymail supports both.
# requirements.txt
Django>=5.2,<5.3
gunicorn
whitenoise
mysqlclient                 # or PyMySQL, see above
django-anymail[brevo]

# settings.py: changes from the VPS version
# Delete SECURE_PROXY_SSL_HEADER: you don't control this proxy.
# Keep CSRF_TRUSTED_ORIGINS, and don't turn on SECURE_SSL_REDIRECT.
MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "whitenoise.middleware.WhiteNoiseMiddleware",   # directly after SecurityMiddleware
    # ... the rest of your middleware
]
STORAGES = {
    "default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
    "staticfiles": {"BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage"},
}
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.mysql",
        "NAME": os.environ["DB_NAME"],
        "USER": os.environ["DB_USER"],
        "PASSWORD": os.environ["DB_PASSWORD"],
        "HOST": os.environ.get("DB_HOST", "localhost"),
        "OPTIONS": {"charset": "utf8mb4"},
    }
}
INSTALLED_APPS += ["anymail"]
EMAIL_BACKEND = "anymail.backends.brevo.EmailBackend"
ANYMAIL = {"BREVO_API_KEY": os.environ["BREVO_API_KEY"]}
DEFAULT_FROM_EMAIL = "hello@example.com"
SERVER_EMAIL = "server@example.com"

Then deploy it from the dashboard:

  1. Create a MySQL database and user under Databases.
  2. Upload the project to the website's app folder (not public_html) over SFTP, or connect your Git repository.
  3. Under Node.js & Python, choose Python 3.12, enter mysite.wsgi:application as the start command (mysite.asgi:application for an ASGI app), and add the same variables as the .env above plus BREVO_API_KEY, with DB_HOST=localhost. Leave out DJANGO_STATIC_ROOT and DJANGO_MEDIA_ROOT, so Django uses the staticfiles and media folders inside the project. PORT is set for you. The first deploy installs requirements.txt and starts the app; after changing requirements.txt, press pip install.
  4. Connect over SSH on port 2222 with your key (the dashboard shows the username and host). The server installs your packages into its own virtual environment, whose path isn't shown, so create a separate one for manage.py commands. If python3 -m venv doesn't work in your shell, open a support ticket. Run the one-off commands, then press Restart in the dashboard:
cd example.com/app                # your app folder; the shell starts in sites/
python3 -m venv .venv-manage && . .venv-manage/bin/activate
pip install -r requirements.txt
export DJANGO_SECRET_KEY=... DJANGO_ALLOWED_HOSTS=example.com DB_NAME=... DB_USER=... DB_PASSWORD=... BREVO_API_KEY=...
python manage.py migrate
python manage.py collectstatic --noinput
python manage.py createsuperuser

Don't skip collectstatic: with the manifest storage, pages fail with "Missing staticfiles manifest entry" until it has run. With Git deploys, each deploy resets tracked files but keeps untracked ones such as .env and .venv-manage, and a .hostethical-deploy.sh file at the repository root runs afterwards as your user, for up to 10 minutes. Put migrate and collectstatic there:

#!/usr/bin/env bash
# .hostethical-deploy.sh in the repository root
set -e
cd "$(dirname "$0")"
set -a; . ./.env; set +a          # an untracked .env you upload to the app folder over SFTP
.venv-manage/bin/pip install -r requirements.txt
.venv-manage/bin/python manage.py migrate --noinput
.venv-manage/bin/python manage.py collectstatic --noinput

If every page returns "Bad Request (400)", Django is rejecting the host name it received: check that your domain, with and without www if you use both, is in DJANGO_ALLOWED_HOSTS, and if it still fails, open a support ticket so we can check which host name reaches your app. If new CSS doesn't show after a deploy, press Restart: WhiteNoise only looks for files when the app starts. For periodic jobs, run a management command from cron the same way. Hosting runs jobs as often as every 5 minutes, on IST server time, and stops each run after 15 minutes. If the domain already runs WordPress, put Django on a subdomain such as app.example.com.

Running Django on HostEthical: web hosting or a VPS?

Web hosting is enough for a small Django site, an internal tool or a portfolio: MySQL, modest traffic, no background workers and no local uploads. It starts at ₹99 a month, or about ₹82.50 a month when billed yearly, with free SSL and nightly backups.

Choose a Cloud VPS when you want PostgreSQL, Celery and Redis, Django Channels, uploads served by Nginx, several apps, or root access. It's unmanaged KVM with a dedicated IPv4 and Ubuntu 24.04 LTS among the OS choices, built automatically after payment, usually within 5 to 15 minutes. Plans start at ₹860 a month, or about ₹774.17 a month when billed yearly. You pay in rupees by UPI or binance Pay (USDT), with no dollar card charges, and the price stays the same at renewal.

PlanvCPURAMStoragePaid monthlyPaid up front, per monthAt renewal
VPS Starter4 cores8 GB100 GB SSD₹860₹774.17 (yearly)Same price
VPS Pro6 cores12 GB200 GB SSD₹1,170₹1,053.33 (yearly)Same price
VPS Max8 cores24 GB300 GB SSD₹2,190₹1,971.67 (yearly)Same price

VPS Starter's 4 vCPU and 8 GB RAM is plenty for most single Django apps, with PostgreSQL, Redis and a Celery worker on the same server. Move to VPS Pro or Max for several busy sites, heavy Celery jobs such as video or machine-learning work, or a large database you want in memory. Building a product with paying customers? See SaaS hosting in India.

Choose Mumbai if your users are in India: requests travel a shorter distance and your data stays in India, for ₹380 a month more than Germany, which suits European users and internal tools (see VPS hosting in Mumbai). You can also register your domain with us, point its A records at the server with our nameservers and DNS editor, and add business email on the same domain.

Deploy your Django project this week. Pick VPS Starter in Mumbai or Germany, pay by UPI, and follow the steps above. See Cloud VPS →

Frequently asked questions

Why does Django return 400 Bad Request after I set DEBUG = False?

With DEBUG off, Django rejects any request whose Host header isn't listed in ALLOWED_HOSTS, and the visitor sees 400 Bad Request. Add your domain and its www form, for example example.com,www.example.com, then restart Gunicorn so it picks up the new value. If Nginx sits in front, make sure it passes the original host with proxy_set_header Host $host.

Why are my CSS and images missing when DEBUG is False?

Django's development server serves static files only while DEBUG is on. In production, run python manage.py collectstatic to copy them into STATIC_ROOT, then serve that folder with an Nginx location /static/ block or with WhiteNoise. On Ubuntu, also check that Nginx can read the folder: home directories are private by default, so keep STATIC_ROOT outside /home, for example under /var/www.

How do I fix "CSRF verification failed. Origin checking failed" behind Nginx?

Django compares the browser's Origin header with the scheme and host it thinks the request used. Behind a proxy it may see plain HTTP while the browser sent https://, so the two don't match. If you control the Nginx server, have it send X-Forwarded-Proto $scheme and set SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https"). Otherwise, or as well, list your origins with the scheme in CSRF_TRUSTED_ORIGINS, such as https://example.com.

Do I need Docker to deploy a Django app?

No. Python, a virtual environment, Gunicorn under systemd and Nginx installed directly on Ubuntu are enough for most Django sites, and leave less to learn. Docker helps when you want the same image on every machine or run services that need different versions, and self-hosted dashboards such as Coolify and Dokploy use it to deploy from Git.

Can I run several Django sites on one VPS?

Yes. Give each site its own folder, virtual environment, PostgreSQL database and .env file, and copy the systemd units under new names, such as site2.socket and site2.service with ListenStream=/run/site2.sock. Add one Nginx server block per domain that proxies to the right socket, and run certbot for each hostname. Watch total memory, because every site's Gunicorn workers share the same RAM.