This repository demonstrates how to deploy a FastAPI application using Coolify with minimal setup.
fastapi-coolify/
├── main.py
└── requirements.txt
- Login to Coolify Dashboard
- Click "+ New" → "Application"
- Select "GitHub"

- Paste the repository link:
https://github.com/t19cs033/fastapi-coolify/
- Set Port Number (we used port 8003, but you can set any port freely. If you change it, make sure to update the port in your source code as well)

- If using Cloudflare Tunnel, specify in Domains:
fastapi.yourdomain.com:8003
- Click "Deploy" button (this takes about 45 seconds)
Access fastapi.yourdomain.com and you should see:
{"message":"Hello World!","status":"success"}If this appears, your deployment was successful.
If you don't want to open ports on localhost or cloud instances, use Cloudflare Tunnel.
Benefits:
- No need to open firewall ports
- Automatic HTTPS
- Enhanced security
- Better performance
Setup Guide: https://coolify.io/docs/knowledge-base/cloudflare/tunnels/overview
from fastapi import FastAPI
import os
app = FastAPI(title="My FastAPI App")
@app.get("/")
def read_root():
return {"message": "Hello World!", "status": "success"}
@app.get("/health")
def health_check():
return {"status": "healthy"}
@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
return {"item_id": item_id, "q": q}
# Coolify configuration
if __name__ == "__main__":
import uvicorn
PORT = int(os.environ.get("PORT", 8003))
uvicorn.run("main:app", host="0.0.0.0", port=PORT)fastapi==0.104.1
uvicorn[standard]==0.24.0- Host Configuration: Use
host="0.0.0.0"(notlocalhost) - Port Flexibility: Port can be customized, just ensure consistency between Coolify settings and source code
- Auto-Detection: Coolify and Nixpacks automatically detect Python environment from
requirements.txt - No Additional Config: No need for
nixpacks.tomlorDockerfile
Local Testing:
pip install -r requirements.txt
python main.py
# Access: http://localhost:8003API Documentation:
- Interactive docs:
http://yourdomain.com/docs - OpenAPI schema:
http://yourdomain.com/openapi.json