This article contains affiliate links — registering through our links may help us earn a commission

Python Django Hosting Guide 2026

Complete guide to choosing the right hosting for your Django applications

Python Django Development on Hosting

Django is a powerful web framework for building web applications with Python — but choosing the right hosting is equally important. Not all standard web hosting services (PHP hosting) properly support Python and Django. This comprehensive guide will help you understand how to select the right hosting, install and configure Django properly, and deploy your application successfully to production.

What is Python/Django Hosting and How is it Different from PHP Hosting?

PHP hosting is designed to directly support PHP code — typically, Apache or Nginx reads .php files and processes the code automatically. Django, however, works completely differently.

A Django application is a long-running process that requires an application server like Gunicorn or uWSGI to handle user requests. Nginx acts as a reverse proxy, forwarding requests to the Gunicorn process running in the background.

The key differences are:

Most standard web hosting providers in Asia are designed primarily for PHP. When you need Django, you'll need a VPS or cloud hosting that gives you full control over the Linux server.

Server Requirements for Django Applications

A Django application needs several components to run properly:

A server suitable for Django should have at least 512 MB to 1 GB of RAM for small applications, and 2 GB or more for medium to large applications. CPU is typically less of a bottleneck than RAM.

Shared Hosting vs VPS vs Cloud for Django

When choosing hosting for Django, consider these three main options:

1. Shared Hosting — Most shared hosting providers don't support Django. Even when they do, there are severe restrictions — you can't install new Python packages, no virtual environment support, and limited control. Not recommended.

2. VPS (Virtual Private Server) — You get full control over a Linux server. You can install Python, Gunicorn, Nginx exactly as you need. Ideal for developers with server management knowledge or team support. Pricing: approximately 200-500 THB/month (Thailand) or 500-1000 THB (Singapore).

3. Cloud Hosting (AWS, Google Cloud, DigitalOcean) — Highly flexible with auto-scaling capability but more expensive (starting 250-1000 THB/month). Best for applications with variable traffic or that need to scale frequently.

For beginners, a VPS in Thailand or Singapore is the best option — affordable pricing, sufficient for medium applications, and you can learn Linux administration alongside development.

How to Install Python and Django on VPS

Assuming you have a VPS running Ubuntu 22.04 LTS, follow these steps to install Python 3.11 and Django:

Step 1: Update server and install dependencies

sudo apt update
sudo apt upgrade -y
sudo apt install -y python3.11 python3.11-venv python3-pip build-essential libpq-dev

build-essential is needed to compile Python packages with C extensions. libpq-dev is essential for PostgreSQL integration.

Step 2: Verify Python version

python3.11 --version
pip3 --version

Step 3: Create project directory

mkdir -p /home/django
cd /home/django
sudo chown -R $USER:$USER /home/django

Step 4: Create virtual environment

python3.11 -m venv venv
source venv/bin/activate

Your prompt should now show (venv) user@server:/home/django$ — this confirms the virtual environment is active.

Step 5: Install Django

pip install --upgrade pip
pip install django gunicorn psycopg2-binary

Now create your Django project:

django-admin startproject mysite
cd mysite
python manage.py migrate

This creates essential files like manage.py, settings.py, urls.py, and wsgi.py.

Configuring Gunicorn + Nginx for Django Production

Next, configure Gunicorn to run your Django application and Nginx to act as a reverse proxy.

Step 1: Set up Gunicorn

First, test Gunicorn:

cd /home/django/mysite
source ../venv/bin/activate
gunicorn mysite.wsgi:application --bind 0.0.0.0:8000

If it works, create a Systemd service file for continuous operation:

sudo nano /etc/systemd/system/gunicorn.service

Add this content:

[Unit]
Description=Gunicorn Django Application
After=network.target

[Service]
User=www-data
WorkingDirectory=/home/django/mysite
ExecStart=/home/django/venv/bin/gunicorn mysite.wsgi:application --bind unix:/home/django/mysite/gunicorn.sock --workers 3
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

Save and enable the service:

sudo systemctl daemon-reload
sudo systemctl enable gunicorn
sudo systemctl start gunicorn
sudo systemctl status gunicorn

Step 2: Install and configure Nginx

Install Nginx:

sudo apt install -y nginx

Create Nginx configuration:

sudo nano /etc/nginx/sites-available/mysite

Add this configuration:

upstream django {
    server unix:/home/django/mysite/gunicorn.sock fail_timeout=0;
}

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location = /favicon.ico { access_log off; log_not_found off; }

    location /static/ {
        alias /home/django/mysite/static/;
    }

    location /media/ {
        alias /home/django/mysite/media/;
    }

    location / {
        proxy_pass http://django;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Enable the site:

sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Nginx now acts as a reverse proxy, forwarding HTTP requests to Gunicorn via Unix socket.

Virtual Environment and requirements.txt

A virtual environment is essential — it isolates your project's Python dependencies from the system Python. Benefits include:

Creating requirements.txt:

pip freeze > requirements.txt

This saves all installed packages and their versions. Example requirements.txt:

Django==4.2.2
gunicorn==21.2.0
psycopg2-binary==2.9.7
Pillow==10.0.0
celery==5.3.1
redis==4.5.5

Installing from requirements.txt on a new server:

python3.11 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

This installs all packages with the exact same versions, ensuring consistent environments. Keep this file updated whenever you add or remove packages.

Deploying Django App from GitHub

Most Django projects are developed on GitHub. Deployment from GitHub should be automated as much as possible.

Step 1: Set up SSH key on server

Create a deployment SSH key:

ssh-keygen -t ed25519 -f /home/django/.ssh/deploy -C "deploy"
cat /home/django/.ssh/deploy.pub

Copy the public key and add it to GitHub repository settings → Deploy Keys.

Step 2: Clone repository

cd /home/django
git clone [email protected]:yourusername/mysite.git mysite
cd mysite
source ../venv/bin/activate
pip install -r requirements.txt

Step 3: Create deployment script

Create deploy.sh:

#!/bin/bash
cd /home/django/mysite
source ../venv/bin/activate
git pull origin main
pip install -r requirements.txt
python manage.py collectstatic --noinput
python manage.py migrate
sudo systemctl restart gunicorn
sudo systemctl restart nginx
echo "Deploy successful!"

Make it executable:

chmod +x deploy.sh

Step 4: GitHub Actions (Optional)

Create .github/workflows/deploy.yml in your repository for automated deployment:

name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Deploy to VPS
        run: |
          mkdir -p ~/.ssh
          echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy
          chmod 600 ~/.ssh/deploy
          ssh -i ~/.ssh/deploy -o StrictHostKeyChecking=no [email protected] './deploy.sh'

This automates deployment every time you push to the main branch.

Static Files, Media Files and Django Settings for Production

During development, Django serves static files automatically. In production, Nginx should serve them directly.

Configure settings.py:

STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com']
DEBUG = False
SECRET_KEY = os.environ.get('SECRET_KEY', 'fallback-secret-key-not-for-production')
CSRF_TRUSTED_ORIGINS = ['https://yourdomain.com', 'https://www.yourdomain.com']
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

Collect static files:

python manage.py collectstatic --noinput

This command gathers all static files from every app into the STATIC_ROOT directory, where Nginx can serve them directly instead of going through Django.

For media files (user uploads), configure Nginx to serve them directly from the /media/ directory.

PostgreSQL Database for Django

Django supports SQLite, PostgreSQL, MySQL, and Oracle. For production, PostgreSQL is recommended for its performance and excellent tooling.

Step 1: Install PostgreSQL

sudo apt install -y postgresql postgresql-contrib

Step 2: Create database and user

sudo -u postgres psql
CREATE DATABASE mysite_db;
CREATE USER mysite_user WITH PASSWORD 'strong_password_here';
ALTER ROLE mysite_user SET client_encoding TO 'utf8';
ALTER ROLE mysite_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE mysite_user SET default_transaction_deferrable TO on;
GRANT ALL PRIVILEGES ON DATABASE mysite_db TO mysite_user;
\q

Step 3: Configure Django settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'mysite_db',
        'USER': 'mysite_user',
        'PASSWORD': 'strong_password_here',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Step 4: Run migrations

python manage.py migrate

Django tables are now created in PostgreSQL. PostgreSQL advantages include:

RECOMMENDEDAsiaGB.com — Web Hosting & VPS we use and recommend. Servers in Thailand and Singapore, SSD storage, managed via DirectAdmin, 24-hour Thai language support, 99% uptime

AsiaGB.com — hosting & VPS we use and recommend: TH/SG servers, SSD storage, DirectAdmin, 24h Thai support, 99% uptime.

Visit AsiaGB →

FAQ: Common Questions about Django Hosting

1. How much RAM does a Django application need?
For small Django apps (< 100 users), 512 MB RAM is sufficient. For medium apps (100-1000 users), 1-2 GB is needed. For large apps (> 1000 users), 4 GB or more. Set Gunicorn workers to 2 × number of CPU cores + 1.
2. Can SQLite be used in production?
Not recommended. SQLite has concurrency issues — with multiple simultaneous requests, write operations may fail. Use PostgreSQL or MySQL instead.
3. Do I need Redis or Celery?
Not essential for small apps. Redis is useful for caching and session storage. Celery helps when you need background task processing for long-running operations.
4. How do I set up an SSL certificate?
Use Let's Encrypt with Certbot. Install: sudo apt install certbot python3-certbot-nginx. Then: sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com. Certbot automatically configures Nginx with HTTPS.