Python
Fastapi
Run FastAPI app
Posted: June 23, 2026
|
Updated: June 23, 2026
If your file is inside a folder
Project structure:
project/
├── app/
│ └── main.py
Run:
uvicorn app.main:app --reload
Production (without auto reload)
uvicorn main:app --host 0.0.0.0 --port 8000
Or with multiple workers:
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4
If your main.py is inside an api folder, your project likely looks like this:
project/
├── api/
│ └── main.py
Assuming main.py contains:
from fastapi import FastAPI
app = FastAPI()
Run it from the project root directory (the folder containing api) with:
uvicorn api.main:app --reload
Or:
python -m uvicorn api.main:app --reload
The server will start at:
http://127.0.0.1:8000