Linux servers & VPS for Django in production
Running Django on a virtual server you administer: provisioning, users, disks, memory, and the operating system underneath.
Running Django on your own Linux server means owning every layer: the operating system, the firewall, the database, the proxy, and the processes. It is the cheapest option and the clearest way to learn what production needs.
The guides cover setting up and hardening a VPS, provider-specific routes such as DigitalOcean, Hetzner, and Linode, and the maintenance that keeps a server healthy afterwards.
Set it up
Guides that take this from nothing to running in production.
- Deploy Django with Gunicorn and Nginx on Ubuntu
Moving a Django app from local development to production usually fails on the same points: process management, reverse proxy configuration, static files, secrets, TLS, and safe...
- How to Deploy Django on a DigitalOcean Droplet
If you want to deploy Django on a DigitalOcean Droplet, you need more than python manage.py runserver.
- Deploy Django on a Hetzner Cloud Server
Provision a Hetzner Cloud server with the hcloud CLI, cloud firewall, and cloud-init, then run Django with Gunicorn, Nginx, PostgreSQL, and backups.
- Host Multiple Django Sites on One Server
Run several Django projects on one server safely: separate users and virtualenvs, systemd templates, per-site databases, and Nginx blocks.
- Deploy Django on Akamai Cloud (Linode)
Deploy Django on an Akamai Cloud (Linode) compute instance with a Cloud Firewall, Gunicorn, Nginx, managed PostgreSQL, Object Storage for media, and backups.
- Deploy Django on Rocky Linux with SELinux
Deploy Django with Gunicorn and Nginx on Rocky Linux, AlmaLinux, or RHEL with SELinux enforcing: firewalld, file contexts, booleans, and reading AVC denials.
- Deploy Django on Vultr
Deploy a Django app on a Vultr cloud compute instance: choose a plan and region, lock down SSH and the Vultr firewall, install Python, PostgreSQL, Gunicorn, and Nginx, add HTTPS, and set up backups and snapshots.
- Deploy Django on Oracle Cloud Free Tier
Deploy Django on Oracle Cloud Always Free resources: create an Ampere A1 Arm instance, open ports in both the security list and the instance iptables, install the stack on Ubuntu, and know the free tier's limits and reclaim rules.
- Run Django in Production on a Raspberry Pi
Run a Django app reliably on a Raspberry Pi 4 or 5: use 64-bit Raspberry Pi OS on an SSD instead of an SD card, run Gunicorn and Nginx under systemd, expose it safely with Cloudflare Tunnel, and back up off the device.
- Move a Django Site to a New Server
Migrate a production Django site to a new server or provider with minimal downtime: rebuild the stack from code, copy media with rsync, move PostgreSQL with dump and restore or replication, lower DNS TTL, cut over, and keep the old server as a fallback.
- Deploy Django on Google Compute Engine
Deploy Django on a Google Compute Engine VM: create an e2 instance with a service account, install Gunicorn and Nginx, connect to Cloud SQL through the Auth Proxy, store media in Cloud Storage, open firewall rules, and add HTTPS.
- Deploy Django on NixOS With a Declarative Configuration
Deploy Django on NixOS: define Gunicorn, PostgreSQL, Redis, Nginx, and ACME certificates in configuration.nix, package the app with a Python environment, manage secrets with agenix or sops-nix, and roll back safely with generations.
- Deploy Django on FreeBSD With Gunicorn, Nginx, and rc.d
Deploy Django on FreeBSD 14: install Python, PostgreSQL, and Nginx from packages, run Gunicorn as an rc.d service with daemon(8), configure pf firewall rules, get certificates with acme.sh or certbot, and optionally isolate the app in a jail.
- Best Hosting Options for Django Deployment in 2026
Choosing the best hosting for Django deployment is not about finding the cheapest server or the most popular cloud.
- Deploy Django on AWS EC2 Step by Step
To deploy Django on AWS EC2 reliably, you need more than python manage.py runserver.
- Deploy Django on AWS Lightsail
Deploy Django on an AWS Lightsail instance with a static IP, firewall rules, Gunicorn, Nginx, HTTPS, and an optional Lightsail managed PostgreSQL database.
- Provision a Django Server with cloud-init
Use cloud-init user data to provision a Django-ready Ubuntu server on first boot: users and SSH keys, packages, firewall, swap, directories, systemd units, and verification.
- Deploy Django from a Private Git Repository with Deploy Keys
Let a Django server pull code from a private GitHub, GitLab, or Bitbucket repository with read-only deploy keys: SSH config aliases, known_hosts, private dependencies, and alternatives.
- Deploy Django on a Single-Node k3s Cluster
Run Django on a single-node k3s Kubernetes cluster: install k3s, use the bundled Traefik ingress with cert-manager for Let's Encrypt, keep PostgreSQL outside the cluster or back it up properly, and deploy with manifests or Helm.
- Docker vs a Plain VPS for Django
Should you deploy Django with Docker or directly on a VPS with systemd? Compare reproducibility, deploy workflow, performance, debugging, security updates, and team skills, with a recommendation for solo developers, small teams, and growing apps.
- Deploy django CMS to Production
Deploy a django CMS site to production: configure settings for CMS and filer, PostgreSQL, media on object storage, static files, caching of rendered pages and menus, search engine friendly URLs, and a release process for template and plugin changes.
- Connect Django Servers Over a WireGuard Private Network
Use WireGuard to connect Django app servers to PostgreSQL, Redis, and workers across hosts or providers: generate keys, configure wg0 interfaces, bind databases to the tunnel address, restrict firewalls, and keep Django connection settings on private IPs.
Run it well
Tuning, reliability, and operations once it works.
- Add Swap to a Small Django Server
Add a swap file to a 1-2 GB Django server so pip installs, migrations, and traffic spikes do not trigger the OOM killer: sizing, fstab, swappiness, Docker and cloud caveats, and when swap is the wrong fix.
- How to Rotate Django and Gunicorn Logs on Linux
Django and Gunicorn log rotation becomes a production issue as soon as your app writes request logs, error logs, or application logs to disk for more than a few days.
- Enable Automatic Security Updates on a Django Server
Keep a Django server patched automatically: unattended-upgrades on Ubuntu and Debian or dnf-automatic on RHEL, security-only origins, service restarts, reboot windows, exclusions for PostgreSQL, and monitoring.
Check it
Review lists to run before launch or after a change.
- Checklist for Decommissioning an Old Django Server
Shut down an old Django server safely after a migration: confirm no traffic or jobs remain, take final backups, export logs, revoke credentials and keys, remove DNS records and firewall rules, wipe disks, cancel billing, and update documentation.
- Linux Server Hardening Checklist for Django
Harden a Linux server running Django: SSH keys, firewall rules, automatic security updates, least-privilege users, systemd sandboxing, fail2ban, and audit checks.
Fix it
Errors and symptoms, each traced to a cause and a fix.
- Fix a Full Disk on a Django Production Server
Recover a Django server with a full disk: find what uses space, clean logs, journal, Docker images, and old releases safely, handle open files, add alerts.
- Fix UnicodeEncodeError from Locale Settings on Django Servers
Fix UnicodeEncodeError 'ascii' codec errors that appear only in production: check Python's encodings, set a UTF-8 locale or PYTHONUTF8 for systemd, cron, and Docker, and pass explicit encodings.
- Fix "Too many open files" on a Django Server
Fix OSError Errno 24 Too many open files in Gunicorn, Celery, and Nginx: read the real per-process limit, find descriptor leaks with lsof, and raise LimitNOFILE, worker_rlimit_nofile, or Docker ulimits.
- Fix a Django Site That Runs but Cannot Be Reached
Fix a Django site that runs on the server but times out in the browser: check what listens and on which address, open ufw and cloud firewalls, stop binding to 127.0.0.1, and confirm DNS points at the server.
- Fix cPanel Passenger "Web Application Could Not Be Started" for Django
Fix the Phusion Passenger error page We’re sorry, but something went wrong / Web application could not be started for Django on cPanel: set up passenger_wsgi.py correctly, use the app’s virtualenv, read the stderr log, and fix static files and restarts.
- Fix Permission Denied on Django Media Uploads
Fix PermissionError when Django saves uploads: service user ownership, MEDIA_ROOT location, upload file modes, systemd sandboxing, Docker volumes, and SELinux.
- Fix Redis MISCONF RDB Snapshot Errors in Django
Fix the Redis MISCONF error that blocks writes from Django and Celery: find why background saves fail (disk full, permissions, memory overcommit), restore writes safely, and decide whether the instance needs persistence at all.
- Fix Nginx bind() to 0.0.0.0:80 Failed (Address Already in Use)
Fix nginx bind() to 0.0.0.0:80 failed (98: Address already in use) on a Django server: find the process holding port 80 or 443, stop Apache or a stray Nginx, and fix duplicate listen directives and Docker port clashes.
- Fix Gunicorn "Permission denied" Binding to Port 80
Fix Gunicorn Connection in use or Permission denied when binding to port 80 or 443: bind Gunicorn to a high port or Unix socket behind Nginx, or grant CAP_NET_BIND_SERVICE safely instead of running as root.
- Fix pip "externally-managed-environment" on a Django Server
Fix pip error externally-managed-environment on Ubuntu 24.04, Debian 12, and other PEP 668 systems when installing Django: create a virtualenv or use uv, use pipx for tools, and avoid --break-system-packages on servers.
- Fix a Broken Django Virtualenv After an OS Upgrade
Fix a Django virtualenv that breaks after upgrading Ubuntu or Debian or changing the Python version: errors like No module named encodings and bad interpreter, recreating the venv safely, and avoiding downtime during the switch.
- Fix "Permission denied (publickey)" in Django CI Deploys
Fix Permission denied (publickey) and Host key verification failed when GitHub Actions, GitLab CI, or another pipeline deploys Django over SSH: load the private key correctly, add known_hosts, fix authorized_keys permissions, and check the user.
- Fix Django Log File PermissionError [Errno 13] Permission Denied
Fix PermissionError Errno 13 Permission denied for a Django log file such as /var/log/django.log: give the app user ownership, stop root-run commands from creating the file, handle log rotation, or log to stdout instead.
- Fix PostgreSQL Collation Version Mismatch After an OS Upgrade
Fix the PostgreSQL warning database has a collation version mismatch after upgrading Ubuntu, Debian, or a Docker base image under a Django database: reindex affected text indexes, refresh the collation version, and avoid silent index corruption.
- Fix Docker "No Space Left on Device" When Building or Running Django
Fix Docker no space left on device during Django image builds and deploys: measure what docker system df reports, prune build cache, images, and volumes safely, set log limits, and stop CI runners and servers from filling up again.
- Fix "fatal: detected dubious ownership in repository" When Deploying Django
Fix git fatal detected dubious ownership in repository during Django deploys, CI jobs, and Docker builds: understand the safe.directory check, run git as the repository owner, fix ownership, or add a narrow safe.directory entry.
Learning paths through this topic
- Your first production deployment on a VPSFrom a fresh Ubuntu server to a Django site on HTTPS, with the settings and checks that keep it safe.
- Hardening a Django deploymentClose the common gaps in settings, headers, the admin, the server, and the software supply chain.
- Keeping it runningLogs, errors, metrics, uptime, backups, and the runbooks you need before the first incident.