10-19-2026, 02:29 PM
How to deploy a Python app (Django or Flask) on CloudPanel with uWSGI
CloudPanel has a Python site type for Django, Flask, FastAPI and other Python web apps. It creates the domain, a site user and an Nginx vhost that forwards requests to an App Port. For production, CloudPanel's own documentation runs the app with uWSGI, which is already installed with CloudPanel. This guide follows that setup.
Step 1: Create the Python site
Step 2: Upload the app and create a virtual environment
Log in over SSH as the site user and put your project in the site folder:
For Django, also set to your domain, set , and run and inside the virtual environment.
Find your app's WSGI entry point. For Django it's. For Flask, create a in the project root:
Step 3: Create the uWSGI config (as root)
Log in as root and create a config file for the site:
Paste this, then change the paths, the port and the site user to match your site:
The socket port must be the same as the App Port from Step 1, and uid/gid must be the site user so the app never runs as root.
Step 4: Point the Nginx vhost to uWSGI
In CloudPanel, open the site and go to the Vhost tab. The default vhost uses, which suits a development server. For uWSGI, change the block to:
Keep as it is; CloudPanel fills in the site's App Port. Click Save.
To let Nginx serve Django's static files directly, add a block like this above it (adjust the path to your STATIC_ROOT):
Step 5: Restart uWSGI and test
You should see uWSGI listening on . Open your domain in the browser. Then reboot the server once to confirm the app starts on its own.
After code changes, restart uWSGI again with.
Step 6: Add free SSL
Go to SSL/TLS > Actions > New Let's Encrypt Certificate for the site. Guide: How to install free SSL in CloudPanel.
Troubleshooting
Sources (checked October 2026): CloudPanel: Python deployment with uWSGI
Not sure which site type to choose? See What can you host on CloudPanel?
CloudPanel has a Python site type for Django, Flask, FastAPI and other Python web apps. It creates the domain, a site user and an Nginx vhost that forwards requests to an App Port. For production, CloudPanel's own documentation runs the app with uWSGI, which is already installed with CloudPanel. This guide follows that setup.
Step 1: Create the Python site
- Go to Sites > Add Site > Create a Python Site.
- Enter the Domain Name, choose the Python Version and set the App Port, for example 8090.
- Set the Site User and password, then click Create.
Step 2: Upload the app and create a virtual environment
Log in over SSH as the site user and put your project in the site folder:
Code:
ssh site-user@YOUR_SERVER_IP
cd ~/htdocs
rm -rf www.example.com
git clone https://github.com/your-name/your-app.git www.example.com
cd www.example.com
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
deactivateCode:
ALLOWED_HOSTSCode:
DEBUG = FalseCode:
python manage.py migrateCode:
python manage.py collectstaticFind your app's WSGI entry point. For Django it's
Code:
yourproject/wsgi.pyCode:
wsgi.pyCode:
from app import app as applicationStep 3: Create the uWSGI config (as root)
Log in as root and create a config file for the site:
Code:
cd /etc/uwsgi/apps-enabled/
nano www.example.com.uwsgi.iniCode:
[uwsgi]
plugins = python3
master = true
protocol = uwsgi
socket = 127.0.0.1:8090
wsgi-file = /home/site-user/htdocs/www.example.com/yourproject/wsgi.py
virtualenv = /home/site-user/htdocs/www.example.com/venv
chdir = /home/site-user/htdocs/www.example.com
buffer-size = 8192
reload-on-rss = 250
workers = 4
enable-threads = true
close-on-exec = true
umask = 0022
uid = site-user
gid = site-user
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = trueStep 4: Point the Nginx vhost to uWSGI
In CloudPanel, open the site and go to the Vhost tab. The default vhost uses
Code:
proxy_passCode:
location /Code:
location / {
include uwsgi_params;
uwsgi_read_timeout 3600;
uwsgi_pass 127.0.0.1:{{app_port}};
}Code:
{{app_port}}To let Nginx serve Django's static files directly, add a block like this above it (adjust the path to your STATIC_ROOT):
Code:
location /static/ {
alias /home/site-user/htdocs/www.example.com/static/;
}Step 5: Restart uWSGI and test
Code:
systemctl restart uwsgi
ss -tulpn | grep uwsgiCode:
127.0.0.1:8090After code changes, restart uWSGI again with
Code:
systemctl restart uwsgiStep 6: Add free SSL
Go to SSL/TLS > Actions > New Let's Encrypt Certificate for the site. Guide: How to install free SSL in CloudPanel.
Troubleshooting
- 502 Bad Gateway: uWSGI isn't running or uses another port. Check and compare the socket port with the App Port.Code:
systemctl status uwsgi
- Errors after a restart: read the uWSGI logs in .Code:
/var/log/uwsgi/app/
- "ModuleNotFoundError": the virtualenv path is wrong or packages were installed outside it.
- Django "DisallowedHost": add your domain to ALLOWED_HOSTS.
- CSS and images missing in Django: run collectstatic and check the /static/ location block.
Sources (checked October 2026): CloudPanel: Python deployment with uWSGI
Not sure which site type to choose? See What can you host on CloudPanel?

