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

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

Is your Heroku bill climbing? Connected to while over MCP, your agent takes your app as it is, copies your database, and deploys it in France.

## Prerequisites

- An app on Heroku, in Node.js, Python or Go.
- Access to your Heroku account, to 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.
```

Without an account, your agent deploys your app as a trial, in one request. To keep it, open the link it gives you and create your account.

With your account, your agent adds while's MCP server itself. If it asks you to, restart it. On the first call to while, a page opens in your browser. In Claude Code, if it doesn't open, type /mcp, choose while, then Authenticate. On that page, choose your app, or "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 writes while.yaml at the root of your app:

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

Heroku's Node.js example ran on while without a single line changed (source 2).

## Copy your Heroku Postgres database

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

Your agent exports the database with `pg_dump`, then loads it into while.

## Carry over your variables

> You, to your agent: Carry over our Heroku config vars.

Your agent carries your settings over to while. You enter your secret keys yourself: your agent never sees them.

## Replace Heroku Scheduler

> You, to your agent: Bring over the Heroku Scheduler jobs.

Your agent declares them as scheduled jobs, at the same times.

## 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. Once the previous version is back, your agent reads what broke in while's logs, fixes it and deploys again.

## Next steps

- [Deploy a Ruby on Rails app and its PostgreSQL database](/en/guides/deploy-rails/)
- [Deploy a Node.js API and its PostgreSQL database](/en/guides/deploy-node-api-postgresql/)
- [Compare Heroku and while](/en/comparisons/while-vs-heroku/)
- [Compare the hosts that have an MCP server](/en/comparisons/mcp-hosting-claude-code/)

## Sources

1. [Heroku Dev Center, runtime principles (the port given by PORT)](https://devcenter.heroku.com/articles/runtime-principles), 2026-11-01
2. [Heroku on GitHub, the Node.js example with Express (node-js-getting-started)](https://github.com/heroku/nodejs-getting-started), 2026-11-01
3. [Heroku Dev Center, config vars](https://devcenter.heroku.com/articles/config-vars), 2026-11-01

## Questions

### What about my add-ons?

PostgreSQL databases, Redis-compatible caches, S3 storage and scheduled jobs all have their equivalent in while.

### Do I need to write a Dockerfile?

No, while recognizes a Node.js, Python or Go app on its own.

### Can I keep Heroku until I have checked everything?

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