FASTAPI-RUN(1)

πŸ“¦
version 0.136.3 Β· 4 versions
, in fedora 44

πŸ’– 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.py
  • app.py
  • api.py
  • app/main.py
  • app/app.py
  • app/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:

  • app
  • api

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, use 127.0.0.1. to enable public access, like inside a container, use all the IP addresses available with 0.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 port 443 and HTTP on port 80, 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 --reload flag. [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 format some.importable_module:app_name.
  • --proxy-headers, --no-proxy-headers β€” enable/disable X-Forwarded-Proto, X-Forwarded-For, X-Forwarded-Port to 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__.py files) 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 --port option.

⭐ 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