Technical Insights

How to Deploy a Django Project on a Live Server Step-by-Step

By Abishek Khawas • Oct 23, 2025
Deploying a Django project from your local environment to a live server is one of the most rewarding steps in web development. It’s when your project finally becomes accessible to the world. Here’s a simple, step-by-step guide to help you deploy your Django app smoothly in 2025. Step 1: Prepare Your Project for Deployment Before anything, make sure your project is production-ready. Turn off Debug Mode: DEBUG = False Add your domain or IP in ALLOWED_HOSTS: ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com'] Collect all static files: python manage.py collectstatic Step 2: Choose a Hosting Platform In 2025, popular Django hosting options include: 🧩 PythonAnywhere (beginner-friendly) ☁️ DigitalOcean (full control VPS) ⚙️ Render or Railway (modern cloud hosting) 🔥 AWS EC2 (enterprise-level scalability) Each offers SSH access and database support, making deployment straightforward. Step 3: Set Up a Virtual Environment on the Server Once you’ve connected to your server via SSH: sudo apt update sudo apt install python3-pip python3-venv python3 -m venv venv source venv/bin/activate Then install dependencies: pip install -r requirements.txt Step 4: Configure Your Database If using PostgreSQL or MySQL, make sure you’ve updated your settings.py file: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'dbname', 'USER': 'dbuser', 'PASSWORD': 'dbpassword', 'HOST': 'localhost', 'PORT': '', } } Run migrations: python manage.py migrate Step 5: Set Up Gunicorn and Nginx Gunicorn serves your Django app; Nginx handles incoming HTTP requests. Install Gunicorn: pip install gunicorn gunicorn --bind 0.0.0.0:8000 projectname.wsgi Then configure Nginx as a reverse proxy: sudo apt install nginx sudo nano /etc/nginx/sites-available/projectname Example config: server { listen 80; server_name yourdomain.com www.yourdomain.com; location /static/ { root /home/username/projectname; } location / { proxy_pass http://127.0.0.1:8000; } } Enable and restart Nginx: sudo ln -s /etc/nginx/sites-available/projectname /etc/nginx/sites-enabled sudo systemctl restart nginx Step 6: Secure Your Site with HTTPS Install Certbot for free SSL from Let’s Encrypt: sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com Step 7: Test Your Deployment Visit your domain in a browser — if everything’s set up correctly, your Django project is live! 🎉 If you see errors, check logs using: sudo journalctl -u gunicorn sudo tail -f /var/log/nginx/error.log 💡 Final Tip Automate future deployments with GitHub Actions or CI/CD pipelines. This ensures every push updates your live project automatically.