A complete step-by-step guide to deploying your Django application on HostGraber Cloud Hosting — from server setup to going live.
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It powers some of the world's largest websites — Instagram, Pinterest, and Disqus among them. Deploying Django on cloud hosting gives you on-demand scalability, better uptime, and full control over your server environment.
HostGraber's Cloud Hosting is optimized for Python and Django applications — with NVMe SSD storage, root SSH access, and one-click server provisioning. This guide walks you through the entire deployment process step by step.
After provisioning your HostGraber Cloud server, connect to it using SSH from your local terminal. Replace your_server_ip with the IP address from your HostGraber dashboard.
ssh root@your_server_ip
Always start by updating your server packages and installing Python, pip, and other required tools.
apt update && apt upgrade -y apt install -y python3 python3-pip python3-venv apt install -y nginx git curl ufw
Clone your project from GitHub or upload it via SCP/SFTP. We recommend keeping your project in /var/www/.
cd /var/www/ git clone https://github.com/yourusername/your-django-project.git cd your-django-project
Always use a Python virtual environment to isolate your project dependencies from the system Python.
python3 -m venv venv source venv/bin/activate pip install --upgrade pip pip install -r requirements.txt pip install gunicorn
requirements.txt includes django, gunicorn, and any database adapters like psycopg2-binary.Open your settings.py and make these critical production changes:
# settings.py DEBUG = False ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com', 'your_server_ip'] STATIC_URL = '/static/' STATIC_ROOT = BASE_DIR / 'staticfiles' MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media'
DEBUG = True. It exposes sensitive information including your secret key and database settings.Then collect all static files:
python manage.py collectstatic python manage.py migrate
Gunicorn serves as the Python WSGI HTTP server between your Django app and Nginx. Test it first:
gunicorn --bind 0.0.0.0:8000 your_project_name.wsgi
Now create a systemd service file to keep Gunicorn running persistently:
nano /etc/systemd/system/gunicorn.service
Paste the following configuration:
[Unit]
Description=Gunicorn daemon for Django
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/var/www/your-django-project
ExecStart=/var/www/your-django-project/venv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
your_project_name.wsgi:application
[Install]
WantedBy=multi-user.target
Enable and start Gunicorn:
systemctl daemon-reload systemctl start gunicorn systemctl enable gunicorn systemctl status gunicorn
Nginx handles incoming HTTP requests and forwards them to Gunicorn. Create a new server block:
nano /etc/nginx/sites-available/your-django-project
Add the following configuration:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /var/www/your-django-project;
}
location /media/ {
root /var/www/your-django-project;
}
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
Enable the config and restart Nginx:
ln -s /etc/nginx/sites-available/your-django-project /etc/nginx/sites-enabled/ nginx -t systemctl restart nginx
Secure your Django app with a free SSL certificate using Certbot. HostGraber also offers managed SSL certificates for one-click setup.
apt install -y certbot python3-certbot-nginx certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot will automatically configure Nginx for HTTPS and set up auto-renewal. Verify renewal works:
certbot renew --dry-run
Allow only essential ports for security:
ufw allow OpenSSH ufw allow 'Nginx Full' ufw enable ufw status
Visit your domain in a browser. If everything is configured correctly, your Django app will be live over HTTPS. To debug any issues, check the logs:
# Gunicorn logs journalctl -u gunicorn --no-pager # Nginx error log tail -f /var/log/nginx/error.log # Nginx access log tail -f /var/log/nginx/access.log
| Component | Role | Why It's Used |
|---|---|---|
| Django | Python Web Framework | Handles app logic, routing, ORM & admin |
| Gunicorn | WSGI Application Server | Serves Django to Nginx via Unix socket |
| Nginx | Reverse Proxy / Web Server | Handles HTTP/S, static files & load balancing |
| Virtualenv | Python Environment | Isolates project dependencies |
| Certbot / SSL | SSL Certificate Manager | Enables HTTPS with auto-renewal |
| UFW Firewall | Network Security | Restricts ports, blocks unauthorized access |
Get NVMe SSD cloud servers, root SSH access, free SSL, and 99.99% uptime — purpose-built for Python & Django deployments. Plans start at just ₹49/month.
Deploying Django on cloud hosting is the right move for any production-grade Python web application. With Gunicorn as your WSGI server, Nginx as a reverse proxy, SSL via Certbot, and a locked-down firewall — your app is secure, fast, and scalable.
HostGraber Cloud Hosting gives you a managed, high-performance environment to run Django apps with confidence. Need help? Our 24/7 support team is always available to assist with your deployment.
We use cookies to improve your experience on our site. By using our site, you consent to cookies.
Manage your cookie preferences below:
Essential cookies enable basic functions and are necessary for the proper function of the website.
These cookies are needed for adding comments on this website.
Statistics cookies collect information anonymously. This information helps us understand how visitors use our website.
Google Analytics is a powerful tool that tracks and analyzes website traffic for informed marketing decisions.
Service URL: policies.google.com (opens in a new window)
You can find more information in our Privacy Policy and Privacy Policy.