---
title: "Leave Fly.io in 2026: fly.toml, PostgreSQL and variables moved over"
url: https://while.sh/en/guides/migrate-from-fly/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-19
---

# Leave Fly.io without rewriting your app, with your AI (2026)

Your customers want their data in France, or you want your AI to deploy for you? Connected to while over MCP, it takes over your Fly.io app as is, copies the database and deploys it.

> **The short version.** Over MCP, your AI reads your fly.toml, copies your PostgreSQL database and takes over your variables. Your app then runs in France. What matters, like deleting a database, waits for a person's approval.

## Prerequisites

- An app on Fly.io, with its fly.toml.
- The Fly.io command line, to export the database.
- An AI that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.

## Step 1: Give your AI this message

Open your AI in your app's folder and paste this message into it:

```text titre="The message to give your AI"
Connect to while with my account (while.sh/agents), then put my app on while.
```

With your account, your AI adds while's MCP server itself. On the first call to while, a page opens in your browser: choose "A new app", then click Authorize.

## Step 2: Open your app

Your AI gives you your app's address, for example `https://mon-appli.while.cloud`, over HTTPS.

## What your AI does

It reads your fly.toml and carries its settings over to while.yaml (source 1):

| In fly.toml | In while.yaml |
|---|---|
| `internal_port` in `[http_service]` | the service's port, `port` |
| `path` in its `checks` | the health path, `health.path` |
| `[processes]`, like `web` and `worker` | one service per process, `type: worker` for those without an address |
| `memory` and `cpus` in `[[vm]]` | the service's resources, `resources` |
| `min_machines_running = 0` | sleep, `sleep` |
| `[env]` | the service's variables, `env` |

```yaml titre="while.yaml"
apiVersion: while/v1
project: mon-appli
services:
  - name: web
    port: 8080
    health:
      path: /health
  - name: worker
    type: worker
    command: [bin/worker]
databases:
  - name: main
```


<figure class="illus"><img src="/illustrations/guide-migration-1200.webp" srcset="/illustrations/guide-migration-768.webp 768w, /illustrations/guide-migration-1200.webp 1200w" sizes="(min-width: 48rem) 46rem, 100vw" width="1536" height="1024" loading="lazy" decoding="async" alt="Migrate your Fly.io app to while: the PostgreSQL database copied with pg_dump, the variables carried over, secret values typed by a person, the app at its own address before the domain switch, in France" /><figcaption>The database, the variables and the secrets: your AI moves it all, and the app answers at its own address before the domain switch.</figcaption></figure>

## Copy your PostgreSQL database

> You, to your AI: Copy our Fly database to while.

Your AI opens a tunnel to the database with `fly mpg proxy`, exports it with `pg_dump` (source 3), then loads it into while.

## Take over your secrets

> You, to your AI: Take over our Fly secrets.

Fly.io never returns a secret's value (source 2): your AI lists their names, and you enter the values yourself in while. Your AI never sees them.

## Move to your own domain

> You, to your AI: Put the app on www.acme.com.

Your AI declares the domain, you add the DNS records it gives you, and the HTTPS certificate follows.

## Go back to the previous version

> You, to your AI: Go back to the previous version.

In the 30 minutes after a production release, the previous version comes back in a second. After that, it takes a few seconds.

## Next steps

- [Compare Fly.io and while](/en/comparisons/while-vs-fly/)
- [Deploy a Docker container](/en/guides/deploy-docker-container/)
- [Restore a PostgreSQL database](/en/guides/restore-postgresql/)

## Sources

1. [Fly.io, app configuration (fly.toml)](https://docs.fly.io/reference/configuration), 2026-11-05
2. [Fly.io, app secrets](https://docs.fly.io/apps/secrets), 2026-11-05
3. [Fly.io, Managed Postgres and its tunnel (fly mpg proxy)](https://docs.fly.io/postgres/import), 2026-11-05

## Questions

### What about my Fly volumes?

while has no persistent disks: keep your files in an S3 bucket, which your AI declares in one line.

### My app already has its Dockerfile. Does while use it?

Yes, while builds your app with it, like Fly.io does.

### Can I keep Fly.io while I check?

Yes, your app runs on while at its own address before you switch your domain.

### Where do my app and its data run?

In France, at Nextmap. The database is backed up every day, with a way back over 14 days, once a person approves.

### Does my AI see my credentials?

No. You paste them into while, the app uses them, and your AI never sees them. Every call is logged.
