---
title: "Best Python API hosting in 2026: 8 options for FastAPI and Flask"
url: https://while.sh/en/comparisons/python-api-hosting/
author: "Grégoire Mougeolle, co-founder of Nextmap"
updated: 2026-11-19
---

# The best hosting for a Python API in 2026

A FastAPI or Flask API can go to production almost anywhere. What changes is the price of a small server, what the free plan is worth, where the database lives, and whether a Python script can run 24/7. We compared eight Python API hosting options in November 2026.

A Python API, whether it runs FastAPI, Flask or Django REST, can go to production almost anywhere. **The right hosting depends on four things**: the price of a small server, what the free plan is worth, where the database lives, and whether your Python scripts can run 24/7 next to the API. We compared eight Python API hosting options, from the cheapest to the most hands-off.

> **Our verdict.** For a Python API your AI takes to production, while. It is tested with every version and billed by the second, with no subscription. Its database is backed up every day in France. Elsewhere, Fly.io only for several regions of the world, Vercel for an API next to a site already on Vercel, and Scalingo for health data.

## The 8 Python API hosting options at a glance

| Host | Smallest server | Free plan | Database | Closest to France |
|---|---|---|---|---|
| while | See [pricing](/en/pricing/) | A trial with no sign-up, the Libre plan | PostgreSQL with the API, backed up every day | In France |
| Vercel | A function, Pro at $20 per month per person | Hobby, for personal use | From a Marketplace provider | Paris, to pick |
| Render | $7 per month, 512 MB | A service that sleeps | From $6 per month | Frankfurt |
| Railway | Hobby at $5 per month, with $5 of usage | $1 of credit per month after the trial | PostgreSQL on request | Amsterdam |
| Fly.io | $2.19 for 30 days, 256 MB | $1 of credit for 7 days | Managed Postgres from $38 | Paris |
| Heroku | Eco at $5, Basic at $7 per month | None | Essential-0 at $5 per month | Europe |
| Scalingo | €7.20 excl. VAT for 30 days, 256 MB | A free start at sign-up | Starter at €7.20 excl. VAT | Paris |
| Clever Cloud | €4.50 for 30 days, 256 MB | Credits at sign-up | Free for development, dedicated at €5.25 | Paris |

Each host's facts come from its pricing page and documentation, cited as sources.

## The cheapest Python API hosting

For a Python API that answers at any hour, **Fly.io is the cheapest entry**: a 256 MB machine costs $2.19 for 30 days, 512 MB $3.69, billed by the second (source 6). Clever Cloud follows at €4.50 on pico (source 10), then Heroku at $5 on Eco, which sleeps after 30 minutes without traffic (source 8).

With a database, the ranking changes. Fly.io's managed Postgres starts at $38 per month (source 6), while **Clever Cloud** comes to under €10 with its first dedicated database at €5.25 (source 10), **Heroku** to about $12 with a Basic dyno and an Essential-0 database (source 7), and **Render** to $13 (source 3).

## Hosting a Python API for free

**Render** has a free web service, which sleeps after 15 minutes without traffic, and a free Postgres database that expires after 30 days (source 4). **Vercel Hobby** is free, and its terms keep it for personal or non-commercial use (source 2). **Railway** gives $1 of credit per month after the trial (source 5), and Fly.io $1 for 7 days (source 6). For an API that serves a real tool, the sleep delays the first request, and a small paid plan becomes necessary.

## A Python script 24/7, or at a set time

An API answers requests, but many Python projects also have **a script that must run nonstop**, a bot listening to a queue or a chat service, or **a script that runs at a set time**, the morning import or the Monday report. A host that puts to sleep whatever gets no web traffic stops the first one.

At Render, background workers run continuously, with no free instance (source 4). At Heroku, an app with only an Eco worker does not sleep and draws on its 1,000 hours per month (source 8). On Vercel, background work goes through queues, and scheduled work through Cron Jobs that call an API route (source 1). On while, your AI declares **a service with no public address** for the permanent script, or **an automation** for the one that runs at a set time.

<figure class="illus"><img src="/illustrations/apipython-script-1200.webp" srcset="/illustrations/apipython-script-768.webp 768w, /illustrations/apipython-script-1200.webp 1200w" sizes="(min-width: 48rem) 46rem, 100vw" width="1536" height="1024" loading="lazy" decoding="async" alt="Host a Python script 24/7 or at a set time: a Python script that stops with the laptop, then the same script on an always-on worker and an automation that starts it every morning, its credential kept out of the AI's reach, in France" /><figcaption>A script that runs nonstop, another that runs every morning, and their credentials kept safe.</figcaption></figure>

## while, your Python API in production by your AI

**We built while for the apps your AI takes to production.** Claude Code, Cursor or Codex connects to while over MCP, with OAuth. Your Python API is detected, installed from `requirements.txt` and started with uvicorn when its main file, `main.py` for example, is at the root. Otherwise, your AI writes the command.

> You, to your AI: Put my FastAPI app in production on while, with a PostgreSQL database, and run my import script every morning at 7.

- **Your pytest tests run at every production release**, and a failing version does not replace the previous one.
- **A script runs nonstop, or at a set time**, with the same code and the same database as the API.
- **Your credentials [stay in while](/en/security/)**: the API uses them, your AI never sees them, and every call is logged.
- **The database is backed up every day**, with a way back over 14 days, and everything runs in France, at Nextmap.

For the step by step, follow [our guide for a FastAPI app](/en/guides/deploy-fastapi/) or [the one for a Flask app](/en/guides/deploy-flask/).

**Who it is for:** a Python API your AI takes all the way to production, with its data in France.

## Vercel, a FastAPI app as a function

Vercel takes a FastAPI or Flask API with zero configuration: it becomes a single function that scales up and down with traffic. WebSockets follow function duration limits, so clients must reconnect, and shutdown cleanup gets 500 milliseconds (source 1).

**Who it is for:** an API next to a Next.js site, with traffic that comes and goes.

## Render, to start for free

Render takes a Python API to production from a Git repository, free with the sleep, then $7 per month for 512 MB, with a first paid database at $6 (sources 3 and 4). Its closest region is Frankfurt.

**Who it is for:** trying for free, then moving to a small paid instance.

## Railway, in a few minutes

Railway takes a Git repository to production and creates a PostgreSQL database on request, at $5 per month on Hobby with $5 of usage included, then about $10 per GB of memory and $20 per CPU for a full month (source 5).

**Who it is for:** a small project that wants to pay for what it uses.

## Fly.io, the cheapest always-on server

Fly.io runs your machines in many regions, Paris included, by the second (source 6). Its managed Postgres weighs on a small API's bill.

**Who it is for:** an API called from all over the world, at the lowest price.

## Heroku, the classic

Heroku runs a Python API on dynos, from $5 on Eco to $25 on Standard-1X per month (source 7), with a Europe region.

**Who it is for:** an API already on Heroku that must keep running unchanged.

## Scalingo, for compliance in France

Scalingo runs your apps in Paris, at €7.20 excl. VAT for 30 days and 256 MB, and €7.20 excl. VAT for the first Starter database. It is HDS certified on a Business or Enterprise plan with at least two containers (source 9).

**Who it is for:** an API that handles health data.

## Clever Cloud, a French host billed by the second

Clever Cloud runs your Python apps in its French zones, from €4.50 on pico to €16 on XS for 1 GB, billed by the second (source 10).

**Who it is for:** a technical team that wants to tune each instance, in France.

## Which one to choose

| Your situation | Our pick |
|---|---|
| Pay by the second for what runs, with no subscription | while |
| A preview per branch, with its own data | while |
| The team signed in with their email account, a client with a password | while |
| Your AI takes the API to production, in France | while |
| A FastAPI app next to a Next.js site | Vercel |
| Health data | Scalingo |

For a full Django app, read [the best Django hosting](/en/comparisons/django-hosting/), for the database alone, [PostgreSQL hosting](/en/comparisons/managed-postgresql-hosting/), and for a bot, [Discord bot hosting](/en/comparisons/discord-bot-hosting/). To try while, give this message to your AI. The trial is **free, with no sign-up**, and your API has its address **in 3 minutes**.

```text titre="The message to give your AI"
Read while.sh/agents and help me get started with while.
```

## How we chose

On November 19, 2026, we read the pricing pages and documentation of Vercel, Render, Railway, Heroku and Scalingo, cited as sources, and reused our November 18 reading for Vercel, Fly.io and Clever Cloud. Prices are for each host's smallest size, in dollars or euros as they display them. We use while every day, and we compared the eight hosts on price, free plan, database and the scripts that run next to the API.

## Sources

1. [Vercel, Deploy a FastAPI app on Vercel](https://vercel.com/docs/frameworks/backend/fastapi), 2026-11-19
2. [Vercel, Pricing](https://vercel.com/pricing), 2026-11-18
3. [Render, Pricing](https://render.com/pricing), 2026-11-19
4. [Render, Deploy for free](https://render.com/docs/free), 2026-11-19
5. [Railway, Pricing](https://railway.com/pricing), 2026-11-19
6. [Fly.io, Fly.io Resource Pricing](https://fly.io/docs/about/pricing/), 2026-11-18
7. [Heroku, Pricing](https://www.heroku.com/pricing), 2026-11-19
8. [Heroku, Eco Dyno Hours](https://devcenter.heroku.com/articles/eco-dyno-hours), 2026-11-19
9. [Scalingo, Pricing](https://scalingo.com/fr/pricing), 2026-11-19
10. [Clever Cloud, Pricing and estimator](https://www.clever-cloud.com/fr/pricing/), 2026-11-18

## Questions

### What is the cheapest Python API hosting?

For a server that runs all the time, Fly.io, at $2.19 for 30 days with 256 MB (source 6). With a database, Clever Cloud comes to under €10 per month, with €4.50 for the app and €5.25 for the database (source 10).

### Can you host a Python API for free?

Yes, with limits. Render has a free web service that sleeps after 15 minutes without traffic, and a free database that expires after 30 days (source 4). Vercel Hobby is free for personal use. On while, the trial is free with no sign-up.

### How to run a Python script 24/7?

In a service that does not sleep: a lone Heroku worker, a Fly.io machine, a paid Render background worker, or a service with no public address on while. A script that only needs to run at a set time can run as an automation.

### Does a FastAPI app run on Vercel?

Yes. The API becomes a single Vercel Function that scales with traffic. WebSockets follow function duration limits, and shutdown cleanup gets 500 milliseconds (source 1).

### Do I need a Dockerfile for FastAPI or Flask?

No, at most hosts. On while, your API is installed from requirements.txt and started with uvicorn when its main file is at the root. Otherwise, your AI writes the command.

### Do my pytest tests run?

On while, at every production release, and a failing version does not replace the previous one.
