Deploying a NiceGUI application on cPanel can feel like trying to fit a square peg into a round hole—but with the right approach, it’s possible! NiceGUI is a fantastic Python framework for building web-based UIs quickly, but since it relies on WebSockets and a running Python backend, traditional cPanel hosting (which is optimized for PHP and static sites) doesn’t always play nice.
In this comprehensive guide, we’ll explore multiple methods to deploy NiceGUI on cPanel, discuss potential roadblocks, and provide workarounds to get your app up and running.
Why Is Deploying NiceGUI on cPanel Tricky?
Before diving into solutions, let’s understand why cPanel isn’t the most straightforward choice for NiceGUI:
- WebSocket Dependency – NiceGUI relies on WebSockets for real-time interactivity, but many shared cPanel hosts block WebSocket connections.
- No Native ASGI/WSGI Support – cPanel is designed for PHP and static sites, not long-running Python apps like FastAPI (which NiceGUI uses under the hood).
- Port Restrictions – NiceGUI typically needs an open port (e.g.,
8080), but shared hosting often restricts port access.
Despite these challenges, we’ll explore three possible deployment methods, ranked from easiest to most advanced.
Method 1: Using cPanel’s “Python App” Feature (If Available)
Some cPanel hosts (like Aveshost or A2 Hosting) offer a “Setup Python App” option. Here’s how to use it:
Step 1: Prepare Your NiceGUI App
Your app should be structured as a standalone ASGI application. Here’s a minimal app.py:
from nicegui import ui
ui.label("Hello from NiceGUI on cPanel!")
ui.button("Click Me!", on_click=lambda: ui.notify("Button clicked!"))
# Run the app (FastAPI/Uvicorn by default)
ui.run()
Step 2: Upload Files to cPanel
- Go to File Manager → Upload
app.py. - Create a
requirements.txtwith:
nicegui
fastapi
uvicorn
Step 3: Set Up the Python App
- In cPanel, find “Setup Python App” (under “Software”).
- Choose Python 3.6+.
- Set Application root to your app’s directory.
- Set Application startup file to
app.py. - For Application Entry Point, enter
app(the FastAPI instance).
Step 4: Install Dependencies for NiceGUI on cPanel
Option 1: Using cPanel’s GUI (No Terminal Required)
- Upload your
requirements.txtfile- Go to “Configuration Files” in your Python app dashboard.
- Click “Add” and upload your
requirements.txt.
- Install dependencies automatically
- Click “Run Pip Install” and select your
requirements.txtfile. - cPanel will handle the installation for you.
- Click “Run Pip Install” and select your
Option 2: Manual Installation via Terminal
If you have SSH or Terminal access, follow these steps:
- Activate the virtual environment
- Run the following command (you can find this in your Python App dashboard in cPanel):
source /home/username/virtualenv/app/3.6/bin/activate && cd /home/username/app - Replace
usernameand3.6with your actual username and Python version.
- Run the following command (you can find this in your Python App dashboard in cPanel):
- Install dependencies manually
- Once inside the virtual environment, run:
pip install -r requirements.txt - This will install all the required packages (NiceGUI, FastAPI, Uvicorn, etc.).
- Once inside the virtual environment, run:
Step 5: Restart & Access Your App
- Restart the app in cPanel.
- Visit the provided URL (e.g.,
yourdomain.com/python-app).
⚠️ Potential Issues:
- If WebSockets are blocked, interactive features may fail.
- Some hosts kill long-running processes.
Method 2: Running NiceGUI as a Background Process (SSH Required)
If your cPanel allows SSH access, you can manually run NiceGUI in the background.
Step 1: Upload Your App
- Upload
app.pyvia File Manager.
Step 2: Install NiceGUI via SSH
pip install nicegui --user
Step 3: Run the App Persistently
Use screen or tmux to keep it running after disconnecting:
screen -S nicegui_app
python app.py --port=8000 # Use an available port
Detach with Ctrl+A, D.
Step 4: Proxy Requests via .htaccess (Optional)
If cPanel allows reverse proxy rules, add this to .htaccess:
RewriteEngine On
RewriteRule ^nicegui(.*)$ http://localhost:8000$1 [P]
Now, visit yourdomain.com/nicegui.
⚠️ Limitations:
- Requires SSH access (not always available).
- If the server restarts, your app stops.
Method 3: Use a Subdomain with Reverse Proxy (Advanced)
If your host allows custom reverse proxies, you can route a subdomain to NiceGUI.
Step 1: Run NiceGUI on a Local Port
python app.py --port=12345
Step 2: Configure Reverse Proxy in cPanel
- Go to Domains → Subdomains → Create
nicegui.yourdomain.com. - In .htaccess, add:
<IfModule mod_proxy.c>
ProxyPass / http://localhost:12345/
ProxyPassReverse / http://localhost:12345/
</IfModule>
Now, access your app at nicegui.yourdomain.com.
Alternative: Deploy NiceGUI Elsewhere (Recommended)
If cPanel proves too limiting, consider:
- VPS – Full control over ports & processes.
- Render/Heroku – Easy Python app deployment.
- Fly.io – Great for WebSocket apps.
Example VPS deployment:
python3 -m pip install nicegui
python3 app.py --host=0.0.0.0 --port=80
Final Thoughts
While NiceGUI on cPanel is possible, it’s not always smooth. If you must use cPanel, Method 1 (Python App) is the easiest. For reliability, a VPS or cloud host is better.
Got stuck? Drop a comment below, and I’ll help troubleshoot! 🚀

