FastAPI
Deploy a FastAPI app on Replov
A FastAPI app runs on Replov as a Web Service with a public HTTPS address. Replov builds the repository into a container with Nixpacks, recognises FastAPI in main.py or app.py, and starts it with uvicorn listening on the port Replov routes to, so in most projects you leave Start Command empty.
An internal API that only your other services call can run the same way as a Private Service, and a queue consumer as a Background Worker.
Last verified against the product on .
Before you start
- A FastAPI app in a GitHub repository with its dependencies, including uvicorn, in requirements.txt (
fastapi[standard]includes uvicorn). - The FastAPI object named
appin main.py or app.py at the service’s root directory, or your own Start Command (see below).
How Replov builds it
- Replov detects Python from requirements.txt and builds the image with Nixpacks, which installs the dependencies.
- With no version declared, Python 3.12 is used. The build log shows the Python version and where it came from.
- When Start Command is empty, Replov uses
uvicorn main:app --host 0.0.0.0 --port ${PORT:-3000} --forwarded-allow-ips='*'(orapp:appfor app.py) and prints it in the build log as “Detected start command”. - A Dockerfile in the service’s root directory replaces all of this.
Deploy it
- 1
Sign in to Replov and connect GitHub (Connect GitHub / Import from GitHub). Replov asks for access to the repositories you choose.
- 2
Create a project for the repository, then add a service to it.
- 3
Choose Service Type: Web Service, select the repository and Branch, and set Root Directory if the app lives in a subfolder.
- 4
Leave Build Command and Start Command empty. Set Start Command only if your app object has another name or file, for example
uvicorn api.server:app --host 0.0.0.0 --port $PORT. - 5
Add Environment Variables. Store database URLs and API keys as secrets.
- 6
Pick the Compute Tier for this Service (Nano, 0.5 vCPU and 512 MB, runs a small API) and deploy.
Example: main.py and requirements.txt
# main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/health")
def health():
return {"status": "ok"}
# requirements.txt
fastapi
uvicorn[standard]Environment variables and ports
- Replov sets PORT (3000) and routes traffic to it. A custom Start Command must listen on $PORT and bind to 0.0.0.0.
- The detected command trusts the X-Forwarded-* headers from Replov’s proxy, so FastAPI sees https and its redirects (for example a trailing slash) keep visitors on HTTPS. Add
--forwarded-allow-ips='*'if you write your own uvicorn command. - Secrets are encrypted at rest and injected at runtime only; read them with os.environ.
Domains and HTTPS
Every web service and static site gets an HTTPS address of the form <service-name>-<4 characters>.replov.com once it is live.
To use your own domain, open the service, choose Connect Domain and publish the CNAME and TXT records Replov shows at your DNS provider. After verification Replov routes the hostname and issues a Let’s Encrypt certificate automatically. More on HTTPS.
Logs and monitoring
The build log streams while the deployment runs; the first failing command and the lines just above it usually explain a failed build. Runtime logs (with live streaming) and CPU, memory and network metrics are on the service page. See service logs.
Troubleshooting
- “uvicorn: command not found” at start
- uvicorn is not installed. Add
uvicorn[standard](or usefastapi[standard]) to requirements.txt and redeploy. - The build log shows `python main.py` as the start command
- Replov did not find FastAPI in main.py or app.py. Set Start Command to your uvicorn command with
--host 0.0.0.0 --port $PORT. - The deployment fails its reachability check
- A custom Start Command is listening on a fixed port (often 8000) or on 127.0.0.1. Use
--host 0.0.0.0 --port $PORT. - Redirects send visitors to http://
- Your own uvicorn command does not trust the proxy headers. Add
--forwarded-allow-ips='*', or leave Start Command empty.
Related
Deploy your repository on Replov
Connect GitHub, choose a service type and a compute tier, and watch the build log.