Deploy Flask App or Host Flask Application on cPanel
Deploying a Flask application on cPanel might sound tricky, but it’s actually quite straightforward when you break it down step by step. If you’re looking for an easy way to host your Python-based Flask web app on a shared hosting environment, cPanel is a great choice.
- Deploy Flask App or Host Flask Application on cPanel
- Why Deploy Flask App on cPanel?
- Prerequisites
- Watch the Video Tutorial
- Step 1: Log in to cPanel
- Step 2: Create a Python Application in cPanel
- Step 3: Upload Your Flask Application
- Step 4: Install Dependencies
- Step 5: Configure Application Startup File
- Step 6: Test Your Flask Application
- Step 7: Fix Common Deployment Issues
- Setting Up a MySQL Database (Optional)
- Final Thoughts
- Frequently Asked Questions (FAQs)
In this ultimate guide, we’ll walk you through everything you need to know about deploying a Flask application on cPanel, from setting up your environment to configuring the webserver properly.
Why Deploy Flask App on cPanel?
cPanel is widely used for shared hosting and offers a user-friendly interface to manage websites, databases, and applications. Here are a few reasons why deploying Flask on cPanel is a great choice:
- Affordable Hosting: Many shared hosting plans come with cPanel at no extra cost.
- User-Friendly: The GUI makes it easy to manage files, databases, and settings.
- Built-in Features: cPanel comes with MySQL, cron jobs, and other useful tools.
- No Need for a Dedicated Server: You don’t need to manage a VPS or a dedicated server to deploy your Flask app.
Prerequisites
Before we start, make sure you have:
- A cPanel Hosting Account – Ensure your hosting provider supports Python applications.
- Flask Installed Locally – You should have a working Flask app on your local machine.
- A Domain or Subdomain – You need a domain or subdomain pointing to your cPanel account.
- SSH Access (Optional) – Some hosting providers like Aveshost allow SSH access, making deployment easier.
- Python Version Supported – Check if your hosting provider live Aveshost supports Python 3.x.
Watch the Video Tutorial
For an easier way to deploy Flask application on cPanel, watch the YouTube video below. If you prefer a detailed, step-by-step written guide, continue reading.
Step 1: Log in to cPanel
First, log in to your cPanel account. The URL usually looks something like this:
https://yourDomainName.com/cpanel or directly from your Aveshost account dashboard
Once inside, you’ll see various tools for managing your hosting account.
Step 2: Create a Python Application in cPanel
- Scroll down to the Software section and click on Setup Python App.

- Click Create Application and select:
- Select Python Version (preferably 3.9+).
- Application root:
/home/yourusername/yourprojectname
(or any preferred directory). For instance, if your application’s root folder is named flaskapp and you are using your primary domain, the application root directory will be flaskapp. In this guide, we are using a subdomain, so our application root becomes flask.hostplus.top. - Application URL: Select the domain or subdomain you want to use.
- Application startup file: Leave it blank for now (we’ll configure this later).
- Application Entry point: Leave it blank for now (we’ll configure this later).

- Click Create and note the Virtual Environment Path displayed.

Step 3: Upload Your Flask Application
You can upload your Flask app project in two ways:
Option 1: Upload via File Manager
- Go to Files section in the cPanel and click File Manager.
- Inside the File Manager, navigate to the application root directory you set in Step 2.
- Click Upload and select your Flask project’s
.zip
file.

- Extract the
.zip
file after uploading. Right-click the uploaded ZIP file and select ‘Extract‘ to unzip it.
Ensure that all files are located in the flask.hostplus.top folder (or any preferred directory). If they are not, navigate to the extracted folder, select all files, and move them to the flask.hostplus.top folder or your chosen directory.
Note: Be sure to delete the .zip
file after extraction
Suggested Reading: How to Upload Your Website (in 3 Simple Steps)

Option 2: Clone from GitHub
- Open Terminal from cPanel or connect via SSH.
- Navigate to the application directory:
cd /home/yourusername/yourprojectname
- Clone your project from GitHub:
git clone https://github.com/yourusername/your-repository.git
Step 4: Install Dependencies
Your Flask project has dependencies listed in requirements.txt
. You can install them in two ways:
Method 1: Using Setup Python App Page
- Go back to Setup Python App.
- Click the Edit button for your application.
- Find the Configuration files section and enter:
requirements.txt
then click Add button

- Click “Run Pip Install”, then select the requirements.txt file to install the dependencies.
Method 2: Using the Terminal
- Activate the virtual environment: copy and paste the Virtual Environment Path from Step 2 or manually activate the virtual environment.
Virtual Environment Path from Step 2
source /home/cpusrplus/virtualenv/flask.hostplus.top/3.11/bin/activate && cd /home/cpusrplus/flask.hostplus.top
Or manually activate the virtual environment
source /home/yourusername/virtualenv/yourprojectname/3.x/bin/activate
- Install dependencies: In the Terminal, navigate in your project directory and run the command to install the dependencies;
pip install -r requirements.txt
Step 5: Configure Application Startup File
- Within your Flask application’s root directory, modify either
app.py
orconfig.py
to include this:
application = app
- Open Setup Python App and locate your application.
- Find the Application Startup File section: Enter the location of your
app.py
file. In my case, it isapp.py
, then save and restart the application.

- Alternatively, you can keep the
passenger_wsgi.py
file and follow the rest of the process to modify it accordingly. - Locate and edit the
passenger_wsgi.py
file in your project’s root directory. Overwrite its existing content with the sole line:
from app import app as application
- Save the file
- Go back to your Setup Python App page and restart your application
Step 6: Test Your Flask Application
Open your browser and visit your Flask app’s URL. If everything is set up correctly, your application should be live!
Step 7: Fix Common Deployment Issues
Even with correct setup, you may encounter some common errors. Below are solutions to the most frequent problems:
1. Application Error (500 Internal Server Error)
Solution:
- Check the error logs (
stderr.log
). - Ensure that
requirements.txt
is correctly installed. - Verify that the startup file is correctly set.
2. Module Not Found Error
Solution:
- Activate the virtual environment and reinstall dependencies:
source /home/yourusername/virtualenv/flaskapp/3.x/bin/activate pip install -r requirements.txt
3. File Permission Issues
Solution:
- Ensure the correct file permissions are set using:
chmod -R 755 ~/flaskapp
4. Debugging Your Flask App
Solution:
- Review
stderr.log
in the Flask application project folder.
Setting Up a MySQL Database (Optional)
If you want use MySQL Instead of SQLite3:
- Create a MySQL database in cPanel.
- Create a database user and assign it to the database.
- Update your Flask application’s configuration to use the database.
For a step-by-step guide on creating a MySQL database in cPanel, follow this illustrated tutorial: How to Set Up a MySQL Database & User in cPanel (2 Easy Methods).
1. Install MySQL Connector in Your Flask Environment
Since cPanel supports Python virtual environments, do the following:
- Open cPanel and navigate to Terminal.
- Activate your Python virtual environment if you have one:
source /home/your-cpanel-username/virtualenv/flaskapp/3.x/bin/activate
(Adjust the path based on your Python version and environment name)
- Install
mysql-connector-python
orPyMySQL
pip install mysql-connector-python
OR
pip install PyMySQL
2. Update Your Flask Application
Modify your Flask application to use MySQL instead of SQLite.
- Edit
app.py
orconfig.py
and update the database URI:
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://your_db_user:your_db_password@localhost/your_db_name'
- Save the file
For a step-by-step guide on using MySQL instead of SQLite3, follow this: How to Use MySQL instead of SQLite3 in a Flask Application
Final Thoughts
Deploying a Flask application on cPanel might seem challenging at first, but by following these steps, you can have your web app up and running smoothly. Whether you upload via File Manager or use GitHub, install dependencies through cPanel or the terminal, the process remains straightforward if you adhere to best practices.
If you still encounter issues, reach out to your hosting provider’s support or check Flask and cPanel documentation for troubleshooting tips.
Now that your Flask app is live, what will you build next? 🚀
Frequently Asked Questions (FAQs)
Yes, you can use the Setup Python App feature in cPanel to create a virtual environment, upload your Flask project via File Manager, and install dependencies without SSH. However, SSH access makes the process easier and more flexible.
Check the error logs (stderr.log
) in your project directory, ensure the correct Python version is selected, verify that all dependencies are installed, and make sure the application startup file and entry point are correctly configured.
To update your Flask app:
1. Upload the new version of your files via File Manager or Git.
2. If there are new dependencies, install them in the virtual environment.
3. Restart the Python application in the Setup Python App page.
Ensure the necessary database drivers (e.g., mysql-connector-python /
or PyMySQL
psycopg2
) are installed in your virtual environment. Then, configure your Flask app to connect to the database using environment variables or a configuration file.
1. Double-check the entry point and startup file settings in cPanel.
2. Activate the virtual environment and manually test the app using python app.py
.
3. Check the logs for errors related to missing dependencies or incorrect paths.
Most shared hosting environments don’t support Gunicorn or uWSGI directly, but cPanel’s built-in Python application feature (WSGI) handles Flask execution efficiently. For more advanced setups, consider VPS hosting.
passenger_wsgi.py
, and how does it help deploy my Flask app?passenger_wsgi.py
is a script that acts as an interface between your Flask application and the Passenger WSGI server (which cPanel often uses). It sets the correct Python interpreter path and tells the server how to find and run your Flask application.
Suggested Reading:
- How to Deploy Django App on cPanel (The Ultimate Guide)
- How to Deploy Angular App on cPanel: CSR & SSR Guide
- How To Deploy a Node.js App on cPanel (The Ultimate Guide)
- How to Deploy Laravel Project on cPanel
- 50+ Essential Git Commands (With Downloadable Cheat Sheet)
- How to Set Up a PostgreSQL Database and User in cPanel
- How to Set Up a MySQL Database & User in cPanel (2 Easy Methods)
- How to Buy cPanel Hosting for Your Website: Beginner’s Guide