FASTAPI-RUN(1)
π FASTAPI-RUN(1) π
okay bestie, gather round, because this is the fastapi run manual page from the User Commands section and it is literally the moment your lil FastAPI app graduates from "works on my machine" to "serving the whole entire internet". π
β¨ NAME β¨
fastapi run β run a FastAPI app in production mode. π no cap.
πΈ SYNOPSIS πΈ
fastapi run [OPTIONS] [PATH]
π¦ DESCRIPTION π¦
so basically? this is the exact same energy as fastapi-dev(1), except reload is turned off and it's listening on the 0.0.0.0 address. that's the whole glow-up. π
it automatically detects the Python module or package that needs to be imported, based on the file or directory path you hand it. it just knows. iykyk.
if you don't pass a path at all, it tries these, in this order:
main.pyapp.pyapi.pyapp/main.pyapp/app.pyapp/api.py
it also detects the directory that needs to be added to the PYTHONPATH to make the app importable, and adds it for you. so thoughtful fr fr. π«Ά
and it detects the FastAPI app object to use. by default it goes looking in the module or package for an object named:
appapi
otherwise? it just uses the first FastAPI app it finds in the imported module or package. iconic behaviour honestly. π
π OPTIONS π
--host TEXTβ the host to serve on. for local development on localhost, use127.0.0.1. to enable public access, like inside a container, use all the IP addresses available with0.0.0.0. [default:0.0.0.0]--port INTEGERβ the port to serve on. normally you'd have a termination proxy on top (that's another program, bestie) handling HTTPS on port443and HTTP on port80, and passing the communication along to your app. [env var:PORT] [default:8000]--reload,--no-reloadβ enable auto-reload of the server when (code) files change. this one is resource intensive, so use it only during development, okay? [default:no-reload]--workers INTEGERβ use multiple worker processes. mutually exclusive with the--reloadflag. [default:None]--root-path TEXTβ the root path is used to tell your app that it's being served to the outside world with some path prefix set up in some termination proxy or similar.--app TEXTβ the name of the variable that contains the FastAPI app in the imported module or package. if you don't provide it, it's detected automatically. [default:None]--entrypoint,-e TEXTβ the FastAPI app import string, in the formatsome.importable_module:app_name.--proxy-headers,--no-proxy-headersβ enable/disableX-Forwarded-Proto,X-Forwarded-For,X-Forwarded-Portto populate remote address info. [default:proxy-headers]--forwarded-allow-ips TEXTβ comma separated list of IP Addresses to trust with proxy headers. the literal'*'means trust everything. π (yes, everything)--verbose,-vβ show detailed startup output and debug logs: how the FastAPI app was discovered, imported, and configured. perfect for when you're nosy about your own code, which, same. π--helpβ show a help message and exit.
π ARGUMENTS π
PATHβ a path to a Python file or package directory (with__init__.pyfiles) containing a FastAPI app. if you don't provide it, a default set of paths will be tried. [default:None]
π ENVIRONMENT π
PORTβ the port to serve on; same as the--portoption.
β SEE ALSO β
little reminder bestie: this is the production mode one. reload off, 0.0.0.0 on, main character energy only. π
and that's the whole page!! this lil slice of documentation is fastapi-run(1) from User Commands, dated July 2026 β so go run your app, slay, and remember: periodt. πβ¨π¦ππ
π¦ where this page comes from
- fedora 44: python3-fastapi 0.136.3-6.fc44 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms