To deploy a Flask or Django Python application live on Hostinger, set up a Hostinger KVM VPS running Ubuntu, connect via SSH, and build an isolated Python virtual environment for your application code. Next, configure Gunicorn as the WSGI application server managed by a systemd background service, route incoming HTTP traffic through an Nginx reverse proxy, and protect your domain with a free SSL certificate.
Deploying Python Web Applications on Hostinger: The Ultimate Guide
Python frameworks like Django and Flask power everything from lightweight microservices and AI utility wrappers to full-fledged SaaS applications and enterprise platforms. However, taking a locally developed Python app and publishing it live to a global production environment can feel daunting for many developers.
Hostinger provides an ideal, high-performance infrastructure for running Python applications. Thanks to its NVMe SSD storage, dedicated KVM virtualization, automated setup templates, and full root SSH access, Hostinger delivers enterprise-grade hosting at a fraction of traditional server costs.
Whether you are building a lightweight API in Flask or deploying a battery-included web platform in Django, this step-by-step guide will walk you through the full deployment pipeline on Hostinger.
Why Hostinger is Ideal for Students, Freelancers, and Developers
Before diving into the technical setup, it is worth understanding why Hostinger is a top choice among modern Python developers:
-
For Computer Science & Bootcamp Students: Hostinger’s VPS environment gives you hands-on experience with real Linux production servers, Nginx configurations, virtual environments, and SSH management without complex cloud billing structures.
-
For Freelancers & Web Agencies: Delivering client projects on Hostinger guarantees high uptime, low latency, and easily scalable CPU/RAM upgrades as client traffic grows—allowing you to offer high-value web hosting packages.
-
For Full-Stack & Backend Developers: Full root access enables complete freedom to install custom database engines (PostgreSQL, MySQL, Redis), background job queues (Celery), and specific Python runtime dependencies.
Prerequisites Before Deployment
To ensure a smooth live deployment, gather the following before starting:
-
A completed Django or Flask application running locally.
-
A GitHub or GitLab repository containing your project source code.
-
A
requirements.txtfile listing all required Python libraries. -
A registered domain name mapped to your target server IP address.
-
A Hostinger KVM VPS Hosting Plan (Ubuntu 22.04 or 24.04 LTS recommended).
Step 1: Provision Your Hostinger VPS Server
-
Log into your Hostinger hPanel dashboard.
-
Navigate to VPS Setup and select Ubuntu LTS as your operating system.
-
Set up a secure SSH password and copy your server’s dedicated IP address.
-
Open your terminal (macOS/Linux) or Command Prompt/PuTTY (Windows) and log into your server as root:
ssh root@YOUR_SERVER_IP
-
Update system packages to ensure your server has the latest security patches:
sudo apt update && sudo apt upgrade -y
Step 2: Install Python, Dependencies, and Nginx
Install Python 3, pip, venv (virtual environment manager), Git, and Nginx web server:
sudo apt install python3-pip python3-venv python3-dev nginx git curl -y
Verify that Python and Nginx are installed correctly:
python3 --version
nginx -v
Step 3: Clone Your Codebase and Set Up Virtual Environment
-
Navigate to the web directory and clone your application code from GitHub:
cd /var/www
sudo git clone https://github.com/your-username/your-python-repo.git app
cd app
-
Create an isolated Python virtual environment to keep global system packages clean:
python3 -m venv venv
source venv/bin/activate
-
Upgrade
pipand install your application dependencies:
pip install --upgrade pip
pip install -r requirements.txt
pip install gunicorn
Step 4: Configure Application Production Settings
For Django Projects:
-
Open your project settings file (
settings.py):PythonDEBUG = False ALLOWED_HOSTS = ['yourdomain.com', 'www.yourdomain.com', 'YOUR_SERVER_IP'] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') -
Collect static files and execute database migrations:
Bashpython manage.py collectstatic --noinput python manage.py migrate
For Flask Projects:
Ensure your core file (e.g., app.py or wsgi.py) exposes the Flask instance correctly:
from myapp import app
if __name__ == "__main__":
app.run()
Step 5: Configure Gunicorn and Systemd Service
To keep your Flask or Django app running continuously in the background—even after server reboots—create a Systemd service file.
-
Create a systemd socket service:
sudo nano /etc/systemd/system/gunicorn.service
-
Add the following service configuration (replace
appwith your folder name and adjust WSGI paths accordingly):
[Unit]
Description=Gunicorn daemon for Python Web Application
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/var/www/app
ExecStart=/var/www/app/venv/bin/gunicorn --workers 3 --bind unix:/var/www/app/app.sock wsgi:app
[Install]
WantedBy=multi-user.target
-
Enable and start the Gunicorn service:
sudo systemctl daemon-reload
sudo systemctl start gunicorn
sudo systemctl enable gunicorn
Verify that the socket was created successfully:
sudo systemctl status gunicorn
Step 6: Configure Nginx as Reverse Proxy
Nginx will receive web requests on HTTP port 80 and forward them to Gunicorn through the Unix socket.
-
Create a new Nginx configuration file:
sudo nano /etc/nginx/sites-available/app
-
Paste the following configuration block (update
yourdomain.comwith your actual domain):
server {
listen 80;
server_name yourdomain.com www.yourdomain.com YOUR_SERVER_IP;
location /static/ {
alias /var/www/app/staticfiles/;
}
location / {
include proxy_params;
proxy_pass http://unix:/var/www/app/app.sock;
}
}
-
Enable the configuration and test for syntax errors:
sudo ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Step 7: Secure Domain with Free SSL (Certbot)
To protect user data with HTTPS encryption, install Certbot and issue a free Let’s Encrypt SSL certificate:
sudo apt install snapd -y
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot will automatically configure your Nginx server block to redirect HTTP traffic securely to HTTPS.
Performance Optimization & Maintenance Checklist
To maintain maximum application speed and uptime:
-
Enable UFW Firewall: Allow SSH, HTTP, and HTTPS traffic (
sudo ufw allow 'Nginx Full' && sudo ufw enable). -
Environment Variables: Store confidential keys (
SECRET_KEY, database credentials) inside a.envfile rather than committing them to Git. -
Log Monitoring: Inspect live logs whenever troubleshooting issues:
-
Gunicorn logs:
sudo journalctl -u gunicorn -
Nginx access logs:
sudo tail -f /var/log/nginx/access.log -
Nginx error logs:
sudo tail -f /var/log/nginx/error.log
-
Claim Exclusive Hostinger Hosting Discount
Ready to deploy your Flask or Django web application live to the world? Hostinger provides ultra-fast NVMe storage, dedicated KVM VPS resources, top-tier global data centers, and 24/7 technical support—making it the ultimate home for your Python apps.
Take advantage of an EXCLUSIVE 20% EXTRA DISCOUNT on your hosting plan today.
How to Redeem Your Discount:
-
Click the button below to visit the official Hostinger portal.
-
Select your preferred KVM VPS or Web Hosting package.
-
The promotional referral code Meerub will apply automatically at checkout to maximize your savings.

