Murmu Software Infotech is a global software development company offering custom software, website development, mobile apps, AI solutions, SaaS platforms, and enterprise IT systems for healthcare, manufacturing, retail, and startups.
How to Deploy a FastAPI Project on Hostinger Cloud Panel: A Complete Step-by-Step Guide
S
Saurav Kumar2 Min Read
FastAPI has become one of the most popular Python frameworks for building high-performance APIs due to its speed, simplicity, and automatic API documentation. Once your FastAPI application is ready, the next step is deploying it to a production server where users can access it.
In this tutorial, you'll learn how to deploy a FastAPI application on Hostinger Cloud Hosting using the Hostinger Cloud Panel. We'll cover everything from preparing your project to configuring the server, installing dependencies, and setting up a reverse proxy with Nginx.
Prerequisites
Before starting, make sure you have:
A Hostinger Cloud Hosting plan or VPS.
A FastAPI project.
SSH access enabled.
Python 3.9 or later installed.
A domain name (optional but recommended).
Basic knowledge of Linux commands.
Step 1: Create Your FastAPI Project
A typical FastAPI project structure looks like this:
fastapi-app/
│
├── app/
│ ├── main.py
│ └── routes.py
│
├── requirements.txt
├── .env
└── README.md
Example main.py:
Reader Responses
typescriptMSI Editor
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello from FastAPI on Hostinger"}
Create a requirements.txt file:
fastapi
uvicorn
gunicorn
python-dotenv
Install dependencies locally:
pip install -r requirements.txt
Test locally:
uvicorn app.main:app --reload
pip install -r requirements.txt
Verify installation:
pip list
Step 6: Test FastAPI Application
Start the application manually:
typescriptMSI Editor
uvicorn app.main:app --host 0.0.0.0 --port 8000
Visit:
http://server-ip:8000
You should see:
{
"message": "Hello from FastAPI on Hostinger"
}
Stop the server:
CTRL + C
Step 7: Configure Gunicorn
typescriptMSI Editor
Install Gunicorn:
pip install gunicorn
Run the application:
gunicorn -w 4 -k uvicorn.workers.UvicornWorker app.main:app
Explanation:
-w 4 = 4 worker processes
UvicornWorker = ASGI support
app.main:app = FastAPI entry point
sudo apt install certbot python3-certbot-nginx -y
Generate SSL certificate:
sudo certbot --nginx -d yourdomain.com
Verify:
https://yourdomain.com
Your API is now secured with HTTPS.
Step 12: Access FastAPI Documentation
FastAPI automatically generates API documentation.
Swagger UI:
https://yourdomain.com/docs
ReDoc:
https://yourdomain.com/redoc
These interfaces allow developers to test API endpoints directly from the browser.
Deploying a FastAPI application on Hostinger Cloud Hosting is straightforward when using a combination of Python virtual environments, Gunicorn, Systemd, and Nginx. This setup provides a stable, scalable, and production-ready environment for hosting APIs and web applications.
By following the steps outlined in this guide, you can successfully deploy FastAPI projects, secure them with SSL, connect a custom domain, and ensure reliable performance for your users.