Framework Frankfurt, Germany

Deploy FastAPI on Nodion

Nodion recognizes FastAPI or Starlette in your dependencies, installs them with its Python buildpack and starts Uvicorn on your main.py or app.py. Migrations can run as a release step before each new version goes live, and the API runs in Frankfurt, next to a managed PostgreSQL database if you need one.

Deploy to Nodion ›

from 1 EUR / month

Up to 15 € credit when signing up

Detected by
FastAPI or Starlette in your dependencies
Start
uvicorn main:app, one process
Python
3.10 to 3.15, default 3.13
Region
EU Central (Frankfurt)

Deploy FastAPI step by step

  1. Install FastAPI with Uvicorn Nodion starts Uvicorn but does not install it. fastapi[standard] includes it; with plain fastapi, add uvicorn yourself. Pin the Python version in .python-version, because a range picks the newest release. requirements.txt
    fastapi[standard]
  2. Keep the app in main.py or app.py Nodion takes whichever of main.py and app.py contains FastAPI or Starlette and runs uvicorn main:app or uvicorn app:app on 0.0.0.0 and the PORT it sets. Answer / with a 200: it is the default health check path. main.py
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/")
    def root():
        return {"status": "ok"}
  3. Package layout? Add a web line If your app lives in a package such as app/main.py, there is no root file to find. Name the module yourself in a Procfile; the line replaces the default start command. Procfile
    web: uvicorn app.main:app --host 0.0.0.0 --port $PORT
  4. Run migrations on every deploy With Alembic, a release: line runs once per build, after the build and before the new version starts. If it fails, the deploy stops and the running version stays live. Procfile
    release: alembic upgrade head
  5. Create the app and the database Create an application from your repository in the region EU Central, then a PostgreSQL database in the same region, and attach it on the Environment tab: it arrives as DATABASE_URL on the next deploy. Mark API keys as secret, then push.

Good to know

  • TrustedHostMiddlewareNodion's health check calls each instance by its internal address, which is not in allowed_hosts, so the middleware answers 400 and the release never goes live. Add an @app.middleware("http") function after it that returns 200 for /healthz (Starlette runs the middleware added last first), and set /healthz as the health check path in the app settings.
  • More than one workerThe default is a single Uvicorn process. For more, set web: uvicorn main:app --host 0.0.0.0 --port $PORT --workers 2 in a Procfile, or run more instances of the web process.
  • DATABASE_URL and SQLAlchemyNodion's DATABASE_URL starts with postgres://, which SQLAlchemy 1.4 and newer do not accept. Replace the scheme before you pass it on, for example with postgresql+psycopg:// for psycopg 3, which works for sync and async engines.

What Nodion runs for you

  • Deploys without downtime Push to your branch and Nodion builds a new release. Traffic switches once the new instances answer their health check; a failed release leaves the running one in place. Apps with a local volume restart instead, because the disk belongs to one instance.
  • Databases next to the app Managed PostgreSQL, pgvector, MySQL, Valkey and ClickHouse in the same region. Attached databases arrive as DATABASE_URL, REDIS_URL or CLICKHOUSE_URL.
  • Previews per pull request Turn on previews and pull requests from your repository get their own app with its own URL and fresh, empty databases, created automatically or by hand. Forks and bot pull requests are skipped.
  • Workers, cron jobs and scaling Run workers as extra processes of the same app, schedule jobs on the Cron tab, and scale every process to up to 16 instances.
  • Release step With buildpacks, a Procfile release: line runs with every new build. Dockerfile apps, and redeploys or rollbacks to an earlier image, use a release command set on the app itself, which also takes precedence over the Procfile line. On static sites a release step runs in an image that holds only the built files.
  • Logs and metrics Build, release and runtime logs plus CPU, memory, disk and network metrics for every instance in the dashboard.
  • Domains and HTTPS A default hostname with HTTPS from the first deploy; your own domains get certificates automatically.

Further reading

FastAPI on Nodion: questions and answers

Does Nodion run FastAPI with several workers?

Not by default: Nodion starts one Uvicorn process. Add --workers 2 or more to your own web: line, or scale the web process to more instances.

Why does my FastAPI deploy never become ready?

The health check needs a 2xx or 3xx on /. An API without a root route answers 404, and TrustedHostMiddleware answers 400 to the internal address. Add a route, or set a path such as /healthz in the app settings and answer it before the host check.

Do Starlette apps work too?

Yes. Starlette in your dependencies gets the same Uvicorn default, which looks for app in main.py or app.py.

Where does my FastAPI app run?

In the EU Central region in Frankfurt, Germany. Build, registry, the app and its databases, volumes, buckets, logs and metrics stay in that region, and Nodion's API and control plane are hosted in Germany. Nodion GmbH is based in Stuttgart.

Can I use FastAPI in line with the GDPR?

Nodion provides the basis for it: Nodion GmbH is based in Stuttgart, Germany, in the Frankfurt region the app, its databases and volumes run in Germany, and you conclude the data processing agreement (DPA) under Art. 28 GDPR electronically in the dashboard. Whether your setup complies also depends on how you configure and use the app.

How much does it cost to run FastAPI on Nodion?

An app instance starts at 1 EUR per month. The setup in the cost box costs 3.50 EUR per month: App 2 EUR, PostgreSQL 1.50 EUR. Prices are net and billed per second, and you pick bigger sizes or more instances whenever you need them.

Can I use my own domain for my FastAPI app?

Yes. Every app gets a default hostname with HTTPS. Add your own domain on the app's Domains tab; the TLS certificate is issued and renewed automatically.

Give your agent a cloud.

Earn up to 15 € in credit when signing up.

Continue with GitHub

or with email

Stay in the loop.

Product news, no spam. Unsubscribe anytime.