# Moving off Heroku

This guide takes a Heroku app to Komuta one piece at a time: the Procfile, config vars, Postgres, Key-Value Store, Scheduler jobs and domains. You or your coding agent can follow it, and the Heroku app keeps running untouched until the cutover in step 8.

## Is Komuta a good fit?

Check this before you start; moving twice costs more than moving carefully once.

**Komuta fits well if:**

- Your users are in or near Europe. Komuta runs in one region today, Germany-East (`de-east`), while Heroku's Common Runtime offers the US and the EU. See [regions](https://www.komuta.io/docs/getting-started/concepts).
- Your app can be built from a Dockerfile. Komuta doesn't run buildpacks; if the repo has no Dockerfile, AI writes one and opens it as a pull request (step 2).
- Your data is in Postgres, Redis, RabbitMQ or MongoDB. Komuta runs managed **PostgreSQL**, **Valkey** (Redis-compatible), **RabbitMQ** and **DocumentDB** (MongoDB-compatible), each with daily backups from the first day.
- You want the bill to stay flat: fixed resource packages, a spending limit on the account, and traffic that isn't charged per GB.

**Think twice if:**

- You open a review app for every pull request. Komuta has no per-pull-request environments; the closest thing is the preview address a Blue-Green deploy gives the next version of a service.
- Your app runs in a Private Space, or your users need a US region.

## What we offer Heroku users

The [Komuta migration program](https://www.komuta.io/migrate) covers Heroku moves. An engineer goes through your app with you, writes a migration plan with your expected monthly bill, and helps with the Postgres import and the DNS switch. Credit support goes up to USD 1,000; the amount depends on what you move and is agreed on a short call.

## How Heroku concepts map to Komuta

| On Heroku | On Komuta | Notes |
|---|---|---|
| App | Service, inside a project | A project holds the services, databases and jobs that belong together. |
| Buildpacks | Dockerfile | Komuta only builds from a Dockerfile. AI can write the first one for you. |
| `$PORT` | `PORT`, set by Komuta | Komuta sets `PORT` to the service's port, so an app that listens on `$PORT` needs no change. |
| Procfile `web` | The Dockerfile's `CMD` | Keep the same command. |
| Procfile `worker` | A second service from the same repo, with its **Public URL** off | Its **Configuration file** points at a second Dockerfile whose `CMD` starts the worker. |
| Procfile `release` | A start step, or a one-off Job | See step 6. |
| `heroku ps:scale web=2` | **Min and max replicas** | The same number in both gives a fixed count; a range turns on autoscaling (1 to 100). |
| Dyno type | Resource package | A free package for one small service, with a single replica; paid packages from USD 9 a month. |
| Sleeping Eco dynos | Sleeping free services | A free web service sleeps after 30 minutes without traffic and wakes on the next request. Paid services never sleep. |
| Config vars | Environment variables | Three types: **Plain**, **Secret** and **Build**. Paste them in as `.env` text. |
| Heroku Postgres | Managed PostgreSQL | Restored straight from a Heroku backup URL (step 4). Point-in-time recovery is on from the start. |
| Key-Value Store | Managed Valkey | Redis-compatible, over TLS (`rediss://`, port 6379). |
| A RabbitMQ add-on | Managed RabbitMQ | TLS only: `amqps`, port 5671. |
| A MongoDB add-on | DocumentDB | Your MongoDB driver takes the `mongodb://` address the instance gives you. |
| Heroku Scheduler | CronJob | Any five-field cron expression, in the time zone you pick. |
| One-off dyno (`heroku run`) | Job | A Job runs when you click **Run now**. |
| `<app>.herokuapp.com` | An address ending in `.komuta.app` | Works over HTTPS straight away, and keeps working after you add your own domain. |
| Custom domain with ACM | Custom domain | Certificates are issued and renewed automatically. |
| Logplex and log drains | Logs, metrics and alerts | Included on every service, with live tail and search in the console. |
| Pipelines | A service per environment | Each service tracks its own branch; with auto-deploy on, a push to that branch releases it. |

## Step by step

### 1. Take inventory

For each app, write down what runs and what it depends on. With the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli):

```bash
heroku apps --all                 # every app you can reach, across teams
heroku ps -a <app>                # process types, dyno sizes and counts
heroku addons -a <app>            # Postgres, Key-Value Store, Scheduler and the rest
heroku domains -a <app>           # custom domains and their DNS targets
heroku pg:info -a <app>           # Postgres plan, version and data size
```

Scheduler jobs live in the Scheduler dashboard: open it with `heroku addons:open scheduler -a <app>` and copy each command with its frequency.

Third-party add-ons such as email, logging or search are billed through your Heroku account. Before you shut the Heroku app down, open an account with each provider directly; their new keys go into Komuta in step 3.

### 2. Create the services on Komuta

1. Create your account at [komuta.io](https://www.komuta.io), then link GitHub, GitLab or Azure DevOps from the **Integrations** page.
2. In a new project, create a service from the app's repo and branch with **Apps → New App**.
3. If the repo has no Dockerfile, Komuta offers to write one with AI and opens it as a pull request. Merge it before the next deploy; until then, deploys can't find the file.
4. For each `worker` line in the Procfile, add a second service from the same repo. Turn its **Public URL** off and set its **Configuration file** to a Dockerfile whose `CMD` runs the worker command.
5. Pick a resource package close to the dyno you ran, and set the replica count.
6. Create the managed databases. For PostgreSQL, pick the major version `heroku pg:info` shows, or the nearest newer one on offer; it can't be changed after the instance is created. Add Valkey, RabbitMQ or DocumentDB where you used those add-ons.

Leave DNS alone for now.

### 3. Copy the config vars

1. Write them out in `.env` form:

   ```bash
   heroku config -a <app> --shell > heroku.env
   ```

2. Delete the lines that add-ons manage, such as `DATABASE_URL` and `REDIS_URL`; you'll set them from the Komuta connection info in step 5.
3. Paste the rest into the service's environment variables. Komuta detects the format, and up to 500 variables go in at once.
4. Mark passwords, tokens and keys as **Secret**. Variables your build reads need the **Build** type; Komuta ticks it on its own for known prefixes such as `NEXT_PUBLIC_` and `VITE_`.
5. Values the web and worker services share can go into an environment group instead.
6. Delete `heroku.env` afterwards. It holds your secrets in plain text.

### 4. Move your Postgres data

For a database up to 20 GB:

1. Take a fresh backup and print its download link:

   ```bash
   heroku pg:backups:capture -a <app>
   heroku pg:backups:url -a <app>
   ```

2. Paste the link into **Operations → Import from URL** on the Komuta PostgreSQL instance. Heroku keeps it valid for 60 minutes; if it runs out, print a new one.
3. Read the compatibility report. Komuta downloads and inspects the dump and compares it with the target before anything changes.
4. Confirm the import. It isn't a merge, so run it into the new, empty instance.
5. When it finishes, Komuta starts a full backup of the imported data on its own.

Heroku recommends its backup tool for moderately loaded databases up to 20 GB. For a bigger or busier database, dump it yourself and put the file behind an HTTPS link, for example a pre-signed S3, Google Cloud Storage or Backblaze B2 URL:

```bash
pg_dump -Fc --no-acl --no-owner "$(heroku config:get DATABASE_URL -a <app>)" -f heroku.dump
```

Treat this pass as a rehearsal: you'll import the final data again during the cutover (step 8).

### 5. Point the app at the new data services

- **Postgres:** set `DATABASE_URL` to the connection string of the Komuta instance. The connection is always encrypted with a certificate Komuta manages.
- **Key-Value Store to Valkey:** set `REDIS_URL` to the Valkey address. Heroku's Key-Value Store uses self-signed certificates, so many apps switch certificate checks off for it. On Komuta's private address you can switch them back on by giving your client the instance's CA, which the connection info returns as `privateCaCertificatePem`.
- **What stays behind in Redis:** cache and session data can start empty on Valkey. Jobs still waiting in a Redis-backed queue (Sidekiq, RQ, BullMQ) don't come along, so let the queue run empty before the switch.
- **RabbitMQ:** use the `amqps` address on port 5671. If you type the address by hand, the default vhost `/` has to be written as `%2F`.
- **Third-party add-ons:** paste in the keys from the accounts you opened in step 1.

### 6. Replace the release phase and Scheduler jobs

- **Release phase:** Heroku runs the Procfile's `release` command before each release and keeps the old release if it fails. On Komuta, either run the command in the container's start script before the server starts, or run it once as a **Job** with **Run now** before you deploy. With several replicas, a start step runs in every replica; a Job runs it once.
- **Scheduler:** create a **CronJob** for each Scheduler job, with the same command from the same repo. Heroku Scheduler offers every 10 minutes, every hour or every day, with daily times in UTC; a CronJob takes any five-field cron expression and runs in the time zone you choose. Keep **If the next run overlaps** on its default, **Skip the new run**, for jobs that mustn't run twice at once. Heroku says Scheduler can occasionally miss a run; after an interruption, a CronJob can still start a missed run within its **Missed-run recovery period**, 30 minutes by default.

### 7. Test on the Komuta address

Deploy every service and open it on its Komuta address. Check the logs, the connection to the imported database, and a few real requests through the app. If you turn health probes on, point them at a path your app answers: the HTTP probe defaults to `/health` on port 80.

### 8. Cut over

1. A day ahead, lower the TTL of your domain's DNS records as far as your provider allows.
2. Stop writes on Heroku with `heroku maintenance:on -a <app>`, and stop the workers with `heroku ps:scale worker=0 -a <app>`. Scheduler jobs keep running in maintenance mode, so delete them or make sure they can't write. Fir-generation apps have no maintenance mode yet; scale their processes to zero instead.
3. Capture one last backup and import it the same way as in step 4.
4. Add your domain to the Komuta service and create the records it shows: the ownership TXT, the certificate CNAME, and the traffic CNAME to `origin.komuta.app`, which replaces the record pointing at Heroku's DNS target. A root domain needs a DNS provider that supports CNAME flattening.
5. Wait for the domain to show **Active**. DNS changes usually show up within minutes and can take up to 24 hours; **Refresh Validation** checks right away.
6. Leave the Heroku app in maintenance mode, with its dynos at zero, for a few days so you can switch back. Once you're sure, remove its add-ons and the app so Heroku stops billing you.

## Let your coding agent do it

Once Claude Code, Codex or another MCP client is connected to Komuta ([setup guide](https://www.komuta.io/docs/mcp/mcp-setup)), hand it this page with a prompt like this one:

```text
Read https://www.komuta.io/migrate/heroku.md.
Use the Heroku CLI to list my app's process types, add-ons, domains and config var names, without their values.
Then propose a Komuta plan for each process, database and Scheduler job.
Do not change anything on Komuta until I approve the plan.
Do not scale, stop or delete anything on Heroku.
```

## Questions

**What will it cost on Komuta?**
One small service runs free; paid resource packages start at USD 9 a month (November 2026 prices), and managed databases are priced on their own. The [Heroku comparison](https://www.komuta.io/compare/heroku) prices the same small stack on both platforms, and [pricing](https://www.komuta.io/pricing) has the full list.

**Do I have to change my code?**
Usually not. The app keeps reading `PORT`, `DATABASE_URL` and `REDIS_URL`; only their values change. What you add is a Dockerfile if the repo has none, and a start step or Job for the `release` command.

**Can I go back to Heroku if something goes wrong?**
Yes, as long as the Heroku app is still there. Turn maintenance mode off, scale the dynos back up and point DNS at Heroku's target again; data written on Komuta in the meantime has to be carried back by hand.

**I'm stuck. Who do I talk to?**
Email [info@komuta.io](mailto:info@komuta.io) with your app's name and where you're stuck, or book a call on the [migration page](https://www.komuta.io/migrate). Someone on the team answers every message.
