FastAPI hosting
Deploy a FastAPI app with uvicorn, from $1.50 a month
To deploy FastAPI on Makofy, put fastapi and uvicorn in requirements.txt, keep your app object at main:app (or app/main.py), and connect the repo or run makofy deploy. Makofy detects Python 3.12, installs your requirements and starts uvicorn main:app on port 8080. An always-on API costs $3.50 a month; an API that can sleep between requests costs $1.50 on Nap and wakes in about 2 to 6 seconds.
Last updated · By the Makofy team (Muncar Ventures LLC)
What Makofy detects in a Python repo
Without a Dockerfile, Makofy builds Python projects on a python:3.12-slim image. It installs dependencies from whichever file you use and then picks a start command from the framework it finds. For FastAPI that is uvicorn, serving the app object.
| Your repo has | Install step | Start command |
|---|---|---|
requirements.txt + main.py with app = FastAPI() | pip install -r requirements.txt | uvicorn main:app on port 8080 |
app/main.py package layout | Same | uvicorn app.main:app on port 8080 |
pyproject.toml | pip install . (wins if several files exist) | Same detection |
Pipfile | pipenv install | Same detection |
A Dockerfile | Your Dockerfile, as written | Your CMD |
Detection decides the command, but your requirements decide what is installed, so list uvicorn explicitly (FastAPI does not pull it in on its own). Pin versions you care about: the build installs fresh on every deploy.
A minimal FastAPI app
# main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/healthz")
def health():
return {"ok": True}
@app.get("/items/{item_id}")
async def read_item(item_id: int):
return {"item_id": item_id}# requirements.txt
fastapi==0.115.*
uvicorn[standard]==0.32.*Deploy it, step by step
- Start the 7-day free trial at makofy.com. A card is required; you are not charged until the trial ends.
- Push the code to GitHub and create a Makofy app from the repository and branch (default
main). Every push to that branch redeploys. - Or deploy from your machine:
curl -fsSL https://makofy.com/install.sh | sh, thenmakofy loginandmakofy deployin the project folder. Virtualenv folders such as.venvare not uploaded. - Add settings as environment variables (for example
DATABASE_URLor an API key). They take effect on the next deploy. - Visit
https://<app>--<workspace>.makofy.sh/docs: FastAPI’s interactive docs are live over HTTPS. - Optionally set the HTTP health-check path to
/healthzand attach a custom domain.
Workers, concurrency and your own start command
The detected command runs a single uvicorn process. Async endpoints handle many concurrent requests in that one process, which suits most small APIs. If you have CPU-bound or blocking code, run more processes and give them the CPU to match. You can replace the start command when deploying; it runs through a shell, so $PORT expands to the port Makofy assigns.
makofy deploy --command "uvicorn main:app --host 0.0.0.0 --port $PORT --workers 2"Each worker is a separate Python process with its own memory, so two workers fit comfortably on Basic (1 GB, 1 vCPU, $6/month) and four on Pro (2 GB, 2 vCPU, $12/month). On Starter (512 MB, 0.5 vCPU) a single process is usually the right choice.
Which instance type for a FastAPI service
| Instance type | Monthly price | Good fit |
|---|---|---|
| Nap | $1.50 | Internal tools, webhooks, prototypes, ML demos with occasional traffic |
| Starter | $3.50 | An always-on API with modest traffic |
| Basic | $6 | Multiple uvicorn workers, heavier libraries such as pandas |
| Pro | $12 | Busy APIs; protected first when the node is under load |
| Dedicated | $35 | 4 GB with 1 vCPU reserved for model inference or large in-memory data |
Databases and background jobs
Add managed Postgres 18 ($3/month) and paste its connection URL into DATABASE_URL; use it from SQLAlchemy, SQLModel or psycopg like any Postgres server. The database is private to your workspace and backed up nightly. For a cache or job queue, add Redis 8 ($2/month) and set REDIS_URL from its connection URL. Details are in Postgres and Redis.
FastAPI’s BackgroundTasks run inside the web process, which is fine for sending an email after a response. Long jobs belong in a separate background worker (for example an RQ, Dramatiq or Celery worker reading from Redis), and scheduled jobs in a cron service. Both run from the same repository with their own start command.
When a deploy fails
Builds have a 15-minute limit. After the build, the new version has about two minutes to accept connections on its port (or answer your health-check path). If it doesn’t, Makofy marks the deploy unhealthy and puts the previous healthy version back. makofy logs shows the build output and the latest lines from the app, which is usually enough to spot an import error or a missing package.
FAQ
Frequently asked questions
What command does Makofy use to start FastAPI?
It runs uvicorn main:app (or app.main:app) on port 8080. You can replace it with your own command, for example to add --workers 2.
Which Python version does Makofy use?
Detected builds use Python 3.12. For another version, add a Dockerfile based on the Python image you need.
How much does it cost to host a FastAPI app?
From $1.50/month on Nap (sleeps after 15 idle minutes) or $3.50/month always on with Starter. Postgres is $3/month extra.
Do I need to install uvicorn myself?
Yes. Add uvicorn (or uvicorn[standard]) to requirements.txt; Makofy installs exactly what your requirements list.
Can FastAPI apps use WebSockets on Makofy?
Yes. WebSockets work over the app’s HTTPS URL, and on Nap an open connection counts as activity, so the app stays awake while clients are connected.
Related
Deploy your app in a few minutes.
Connect a GitHub repo or run makofy deploy. Flat price per app, 7-day free trial, card required.