How to migrate from Heroku to AWS

Move a Heroku app to AWS: which AWS service replaces each dyno and add-on, how to move your config vars and Postgres data, and what a minimal setup costs.

Last updatedNovember 2026

Heroku runs your dynos, add-ons and config vars from one dashboard and one Procfile. On AWS the same app is spread across several services, which gives you more control over networking, regions and compliance, along with more to set up and operate. This guide maps each part of a Heroku app to its AWS counterpart and walks through the move.

Many teams are planning the move now because Heroku moved to sustaining engineering in February 2026 and the Heroku-22 stack reaches end of life on April 30, 2027. If you want your app on AWS without running ECS, RDS and a VPC yourself, Modelence deploys it there for you. See moving from Heroku to Modelence.

Choose how to run your app

AWS has several ways to run a web app. For an app coming from Heroku, these three are worth a look.

Older Heroku-to-AWS guides often point to App Runner or the Copilot CLI. App Runner stopped accepting new customers on April 30, 2026, and Copilot reached end of support on June 12, 2026.

Where each part of your Heroku app goes

A Heroku app with its add-ons becomes a handful of AWS services that you connect yourself.

On HerokuMoving it to AWS
ProcfileEach process type becomes its own ECS service running the same image with a different command. web sits behind the load balancer, and worker or clock runs without one.
BuildpacksECS runs images and doesn't build from source. Write a Dockerfile, or build an image with Heroku's Cloud Native Buildpacks and pack, which keeps your Procfile process types. Build it in GitHub Actions or CodeBuild.
Dynos and formationEach dyno size becomes a task size, in vCPU and memory, and the dyno count becomes the service’s desired count, with autoscaling on CPU or requests if you want it.
Release phaseRun the release command, usually database migrations, as a one-off ECS task from the new image before you update the services.
Config varsValues go into Secrets Manager or Parameter Store, and the task definition references each one by ARN. ECS reads them when a task starts, so a changed value needs a new deployment.
Heroku PostgresIt moves to Amazon RDS with a backup and restore. A db.t4g.micro instance costs about $14 a month with 20 GB of storage in one availability zone, and twice that with Multi-AZ.
Heroku Key-Value StoreIt moves to Amazon ElastiCache, where Valkey speaks the Redis protocol and a serverless cache starts at about $6 a month. Heroku offers no RDB download, so a cache starts empty and queues drain before the switch.
Heroku SchedulerEventBridge Scheduler runs an ECS task from the same image with the job’s command, on cron or rate expressions in the time zone you choose.
Other add-onsEmail, search, error tracking and monitoring services keep working from AWS. Store their keys in Secrets Manager with the rest.
Logs and log drainsContainer output goes to Amazon CloudWatch Logs, which bills by the GB ingested and stored. Express Mode creates the log group for you.
Pipelines and review appsDeploy the same CDK or Terraform code once per environment as separate stacks, ideally with production in its own AWS account. Per pull request stacks come from your CI.
Private SpacesServices and databases reach each other inside a VPC, and security groups decide which of them can connect.
Custom domainsRoute 53 alias records work on the root domain, and ACM certificates on a load balancer are free.

Moving your app

These steps use ECS Express Mode with RDS Postgres. The order is the same for the other options.

1. Rotate your keys and take stock of the app

Moving is a good time to rotate the API keys and passwords in your config vars, so issue new ones first and keep the new values for AWS. Then list what the app uses:

heroku config --shell -a your-app
heroku addons -a your-app
heroku ps -a your-app

--shell prints one KEY=value line per variable and quotes values with special characters. heroku addons shows the databases and services to recreate or keep, and heroku ps shows how many dynos of each type and size you run. Note your Scheduler jobs and domains too.

2. Build an image and push it to ECR

Write a Dockerfile that runs the same commands as your Procfile, or build the image with Heroku's builder for your stack. Then create a repository and push it:

pack build ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/web:v1 --builder heroku/builder:24
aws ecr create-repository --repository-name web
aws ecr get-login-password | docker login --username AWS \
  --password-stdin ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com
docker push ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/web:v1

3. Create the database and cache, and store your secrets

Create the RDS instance in private subnets, with a security group that only accepts connections from the app, and a serverless Valkey cache in the same subnets if the app uses Redis:

aws elasticache create-serverless-cache --serverless-cache-name cache \
  --engine valkey --subnet-ids subnet-aaa subnet-bbb --security-group-ids sg-ccc

Then store the connection strings and your other config vars:

aws secretsmanager create-secret --name web/DATABASE_URL \
  --secret-string "postgresql://USER:PASSWORD@HOST:5432/app"

4. Deploy the services

Create the web service with ECS Express Mode, with its secrets referenced from Secrets Manager. AWS's pages list different default sizes, so set CPU, memory and the health check path yourself:

aws ecs create-express-gateway-service --service-name web \
  --execution-role-arn arn:aws:iam::ACCOUNT_ID:role/ecsTaskExecutionRole \
  --infrastructure-role-arn arn:aws:iam::ACCOUNT_ID:role/ecsInfrastructureRoleForExpressServices \
  --primary-container '{"image": "ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/web:v1",
    "containerPort": 3000, "environment": [{"name": "PORT", "value": "3000"}],
    "secrets": [{"name": "DATABASE_URL",
    "valueFrom": "arn:aws:secretsmanager:us-east-1:ACCOUNT_ID:secret:web/DATABASE_URL"}]}' \
  --cpu 256 --memory 512 --health-check-path /

Heroku set PORT for you, so the command sets it to the container port. It returns a URL once the service is healthy. Create each worker as a regular ECS service from the same image, with its Procfile command and no load balancer. In an image built with pack, that is the entry point /cnb/process/worker. For later deploys, the aws-actions/amazon-ecs-deploy-express-service GitHub Action pushes each new image, and a one-off aws ecs run-task runs your release command before it.

5. Do a test run of the database copy

The data moves as a backup and restore while the Heroku app is in maintenance mode, so do a test run first to know how long that window will be. Run it from a machine that can reach both Heroku and RDS, such as a small EC2 instance in a public subnet of the VPC, with the Heroku CLI and the PostgreSQL client installed. Capture a backup, download it and restore it into RDS:

heroku pg:backups:capture -a your-app
curl -o latest.dump "$(heroku pg:backups:url -a your-app)"
pg_restore --verbose --clean --if-exists --no-acl --no-owner \
  -d "$RDS_URL" latest.dump

The backup URL expires after 60 minutes. --no-owner and --no-acl matter on RDS, where the master user isn't a superuser and Heroku's roles don't exist. If your database is on Heroku Postgres Advanced, you can instead replicate it to RDS with logical replication while the Heroku app keeps serving.

6. Switch over and move the domain

Recreate each Scheduler job as an EventBridge Scheduler schedule that runs an ECS task. Lower the TTL on your DNS record a day ahead. When you are ready, put the Heroku app in maintenance mode, and let the workers finish what is queued before you stop them:

heroku maintenance:on -a your-app
heroku ps:scale worker=0 -a your-app

Capture a fresh backup and restore it into RDS with the same commands as in the test run. Request an ACM certificate for your domain, add it to the load balancer and point the DNS record at it in place of the herokudns.com target. Once traffic has moved over, delete the Heroku app along with its add-ons and any tokens it held.

What a minimal setup costs

One small web service with Postgres in us-east-1, running all month at on-demand prices.

Load balancer

ALB hourly charge, before traffic

$16.43

Postgres

RDS db.t4g.micro, one AZ, 20 GB gp3

$13.98

Web container

Fargate, 0.25 vCPU and 0.5 GB

$9.01

Public IPv4 address

On the task, in a public subnet

$3.65

DNS

Route 53 hosted zone

$0.50

NAT gateway

Only for tasks in private subnets, per AZ

+$32.85

Monthly total without NAT

about $44 to $50

The load balancer is the largest fixed cost, and it adds a small charge per unit of traffic on top. Each worker process adds a Fargate task of its own, and a serverless Valkey cache starts at about $6 a month. A NAT gateway costs more than the app and the database together, so keep tasks in public subnets unless you need them private. Logs, data transfer out and Secrets Manager, at $0.40 per secret a month, come on top.

The figures come from AWS's pricing pages for Fargate, load balancers, RDS, ElastiCache and VPC as of November 2026.

AWS without the setup

Modelence runs your app on AWS Fargate across two availability zones, and creates its managed Postgres, MongoDB or Redis alongside it. Your coding agent turns your Procfile into one config file, and the deploy creates the rest.

Read the guide to moving from Heroku to Modelence, or paste this into your coding agent to start:

Frequently asked questions (FAQs)

What is the AWS equivalent of Heroku?

ECS Express Mode is the closest for a web dyno. It turns a container image into a running service with a load balancer, HTTPS, autoscaling and logs. Workers run as more ECS services, and the add-ons map to separate AWS services: RDS for Postgres, ElastiCache for the Key-Value Store, Secrets Manager for config vars and EventBridge Scheduler for Heroku Scheduler.

Can I use AWS App Runner or Copilot?

Not on a new account. App Runner stopped accepting new customers on April 30, 2026, and AWS recommends ECS Express Mode for new services. The Copilot CLI that many older Heroku-to-AWS guides use reached end of support on June 12, 2026.

How do I move Heroku Postgres to RDS?

Capture a backup with heroku pg:backups:capture, download it from the URL heroku pg:backups:url prints, and restore it into RDS with pg_restore and the --no-owner and --no-acl flags. Do a test run to time it, then repeat the copy with the Heroku app in maintenance mode when you switch.

How much does it cost to run a small Heroku app on AWS?

About $44 to $50 a month in us-east-1 for one small Fargate task, a load balancer and the smallest RDS Postgres instance, before logs and data transfer. A serverless Valkey cache adds from about $6 a month, each worker adds its own Fargate task, and a NAT gateway adds about $33 a month per availability zone.

Do I need a Dockerfile?

For ECS, you need a container image, and you can build one without a Dockerfile using Heroku’s Cloud Native Buildpacks and the pack CLI, which keeps your Procfile process types. Elastic Beanstalk builds from source and reads a Procfile, so it needs no image at all.

How do I replace Heroku Scheduler?

Create an EventBridge Scheduler schedule for each job, with an ECS task as the target running the job’s command from your app’s image. Schedules take cron or rate expressions and a time zone, so a job can run at an exact time instead of every 10 minutes, every hour or every day.

Can I run on AWS without setting all of this up?

Yes. Modelence deploys your app and its databases to AWS in the region you choose, from one config file your coding agent writes from your Procfile, and keeps them running after the deploy. See the guide to moving from Heroku to Modelence.

Run your app on AWS without operating it

Modelence deploys it to the AWS region you choose. Start on the Free plan.

Or paste this into your coding agent