Deploy Django on AWS or VPS (Step-by-Step Guide for Beginners 2026)
Introduction
Deploy Django on AWS is one of the most important skills for developers who want to move their project from local development to a live production server.
In this guide, you will learn how to deploy a Django application using a VPS or Amazon Web Services with a production-ready setup using Nginx and Gunicorn.
Why Deploy Django on AWS or VPS
When you deploy a Django project, you make it accessible to users over the internet.
AWS provides scalability and reliability for large applications. VPS hosting is more affordable and suitable for beginners.
Popular VPS providers include DigitalOcean, Linode, and Hostinger.
Deployment Architecture
User Request → Nginx → Gunicorn → Django → Database
This architecture ensures better performance and handling of user requests.
Step 1: Connect to Your Server
To begin, connect to your server using SSH:
ssh ubuntu@your_server_ip
Step 2: Install Required Packages
sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip python3-venv nginx git -y
Step 3: Upload Your Django Project
Clone your project from GitHub:
git clone https://github.com/yourusername/project.git
cd project
Step 4: Setup Virtual Environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Step 5: Configure Django Settings
Open your settings.py file and update:
DEBUG = False
ALLOWED_HOSTS = ['your_server_ip', 'yourdomain.com']
Step 6: Apply Migrations and Collect Static Files
python manage.py migrate
python manage.py collectstatic
Step 7: Run Gunicorn
pip install gunicorn
gunicorn --bind 0.0.0.0:8000 project.wsgi:application
Step 8: Configure Nginx
Create a configuration file:
sudo nano /etc/nginx/sites-available/project
Add the following configuration:
server {
listen 80;
server_name your_domain_or_ip; location /static/ {
root /home/ubuntu/project;
} location / {
include proxy_params;
proxy_pass http://127.0.0.1:8000;
}
}
Enable and restart Nginx:
sudo ln -s /etc/nginx/sites-available/project /etc/nginx/sites-enabled
sudo nginx -t
sudo systemctl restart nginx
Step 9: Enable HTTPS with SSL
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx
Step 10: Connect Your Domain
Buy a domain and point it to your server IP using DNS A record.
Common Errors and Fixes
502 Bad Gateway
This usually means Gunicorn is not running. Restart the service.
Static Files Not Loading
Run collectstatic again and verify static file paths.
Permission Denied
Check file and folder permissions on your server.
Best Practices for Production Deployment
- Use PostgreSQL instead of SQLite
- Set DEBUG to False
- Use environment variables for secrets
- Enable firewall rules
- Optimize static files
External Resource
You can refer to official documentation of Amazon Web Services for more advanced deployment setups.
Internal Linking Ideas
- Django Interview Questions
- Python Projects for Beginners
- Gunicorn and Nginx Deployment Guide
Frequently Asked Questions
What is the easiest way to deploy Django on AWS?
Using EC2 with Nginx and Gunicorn is the most common and recommended approach.
Can beginners deploy Django on VPS?
Yes, VPS hosting is beginner-friendly and cost-effective.
Do I need Nginx for deployment?
Yes, Nginx improves performance, handles static files, and acts as a reverse proxy.
Conclusion
Deploy Django on AWS or VPS is an essential skill for developers. With tools like Nginx and Gunicorn, your application becomes production-ready, secure, and scalable.