---
title: "Migrate from Railway over MCP, without a rewrite"
url: https://while.sh/en/guides/migrate-from-railway/
author: "Aloïs Oddon, co-founder of Nextmap"
updated: 2026-11-05
---

# Leave Railway without rewriting your app, from your AI agent

Your customers want their data in France, or you want an agent that deploys for you? Connected to while over MCP, it takes over your Railway app as is, copies the database and deploys it.

## Prerequisites

- An app on Railway, in Node.js, Python or Go, or with its Dockerfile.
- The Railway command line, to read your variables and export the database.
- An AI agent that works in a terminal: Claude Code, Codex, Cursor or Gemini CLI.

## Step 1: Give your agent these instructions

Open your agent in your app's folder and paste these instructions into it:

```text titre="Instructions"
Connect to while with my account (while.sh/agents), then deploy my app.
```

With your account, your agent 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 agent gives you your app's address, for example `https://mon-appli.while.cloud`, over HTTPS.

## What your agent does

It reads your railway.json or railway.toml, if there is one (source 1), and carries its settings over to while.yaml:

| In railway.json | In while.yaml |
|---|---|
| `startCommand` | the service's command, `command` |
| `healthcheckPath` | the health path, `health.path` |
| `cronSchedule` | a scheduled job, in `crons` |
| `dockerfilePath` | the service's Dockerfile, `dockerfile` |

```yaml titre="while.yaml"
apiVersion: while/v1
project: mon-appli
services:
  - name: web
    health:
      path: /health
databases:
  - name: main
```

## Copy your Railway database

> You, to your agent: Copy our Railway database to while.

Your agent exports the database with `pg_dump`, through the database's public address (`DATABASE_PUBLIC_URL`) or through a Railway command-line tunnel, then loads it into while (source 3).

## Carry over your variables

> You, to your agent: Carry over our Railway variables.

Your agent reads your variables with `railway variable list` (source 2) and carries them over to while. Sealed variables don't come out (source 2): those, and your secret keys, you enter yourself in while, and your agent never sees them.

## Move to your own domain

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

Your agent 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 agent: Go back to the previous version.

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

## Next steps

- [Compare Railway and while](/en/comparisons/while-vs-railway/)
- [Railway pricing](/en/comparisons/railway-pricing/)
- [Restore a PostgreSQL database](/en/guides/restore-postgresql/)

## Sources

1. [Railway, config as code (railway.json, railway.toml)](https://docs.railway.com/config-as-code/reference), 2026-11-05
2. [Railway, the railway variable command](https://docs.railway.com/cli/variable), 2026-11-05
3. [Railway, backing up and restoring Postgres](https://railway.com/guides/postgres-backups-restores), 2026-11-05

## Questions

### My app has no railway.json or railway.toml. Is that a problem?

No: your agent starts from your code, which while detects automatically in Node.js, Python or Go, or from your Dockerfile.

### Do I need to write a Dockerfile?

No, a Node.js, Python or Go app is detected automatically. If your app already has its own, while uses it.

### Can I keep Railway while I check?

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