Railway runs your services, databases and variables from one dashboard. 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 Railway project to its AWS counterpart and walks through the move.
If you are moving after Railway's October security incident, rotate the keys you kept in Railway variables first and put the new values straight into AWS.
If you want your app on AWS without running ECS, RDS and a VPC yourself, Modelence deploys it there for you. See moving from Railway to Modelence.
Choose how to run your app
AWS has several ways to run a container. For an app coming from Railway, these three are worth a look.
The closest match to Railway
ECS Express Mode
You give it a container image and two IAM roles, and it creates a Fargate service with a load balancer, an HTTPS certificate, autoscaling and logs, then returns a URL. AWS launched it in November 2025 and now recommends it in place of App Runner and the Copilot CLI.
For full control
ECS on Fargate, set up yourself
You define the VPC, load balancer, task definitions and deploys in CDK, Terraform or CloudFormation. It takes the most setup, and it lets you add sidecars, private subnets and custom deploy strategies.
For small apps on a fixed price
Lightsail containers
A flat monthly price per node, from $7 for 0.25 vCPU and 512 MB, with data transfer included. It has fewer options than ECS, and a managed database there starts at $15 a month.
Older Railway-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 Railway project goes
A Railway service with a database becomes a handful of AWS services that you connect yourself.
| On Railway | Moving it to AWS |
|---|---|
| Services | Each Railway service becomes its own ECS service on Fargate, running a container image you push to Amazon ECR. |
| Builds | ECS runs images and doesn’t build from source, so add a Dockerfile if Railway built the app with Railpack, and build it in GitHub Actions or CodeBuild. |
| Config as code | The start command, health check, CPU and memory from railway.json or railway.toml move into an ECS task definition, which you keep in CDK, Terraform or CloudFormation. |
| Variables | Values 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. |
| Reference variables | AWS has no ${{Postgres.DATABASE_URL}} syntax, so store the connection string as a secret and reference it from every service that needs it. |
| Postgres | It moves to Amazon RDS with logical replication. A db.t4g.micro instance costs about $12 a month in one availability zone and twice that with Multi-AZ, and Aurora Serverless v2 can pause when idle. |
| Redis | It moves to Amazon ElastiCache, where Valkey is the cheaper engine and speaks the Redis protocol. A serverless Valkey cache starts at about $6 a month. |
| MongoDB | It moves to MongoDB Atlas on AWS, which can be billed through AWS Marketplace, or to Amazon DocumentDB, which is compatible with the MongoDB API, so check the features your app uses. |
| MySQL | It moves to Amazon RDS for MySQL, sized and priced like the Postgres instances. |
| Volumes | Amazon EFS mounts into Fargate tasks as a shared file system. For uploads and other files the app reads back by key, S3 is simpler and cheaper. |
| Cron jobs | EventBridge Scheduler runs an ECS task from the same image with a different command, with no five-minute minimum between runs. |
| Private networking | Services and databases reach each other inside a VPC, and security groups decide which of them can connect. |
| Environments | Deploy the same CDK or Terraform code once per environment as separate stacks, ideally with production in its own AWS account. |
| Custom domains | Route 53 alias records work on the root domain, and ACM certificates on a load balancer are free. |
| Logs and metrics | They go to Amazon CloudWatch, which bills logs by the GB ingested and stored. Express Mode creates the log group for you. |
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 project
Moving is a good time to rotate the API keys and passwords stored in your variables, so issue new ones first and keep the new values for AWS. Then list what each service uses:
railway variables --kv --service api --environment productionSealed variables don't show up there, so check the dashboard for those, and note each service's databases, volumes, cron schedule and domains.
- 2
Build an image and push it to ECR
If Railway built the app with Railpack, write a Dockerfile that runs the same start command. Then create a repository and push the image:
aws ecr create-repository --repository-name api aws ecr get-login-password | docker login --username AWS \ --password-stdin ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com docker build -t ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/api:v1 . docker push ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/api:v1 - 3
Create the database and store your secrets
Create the RDS instance in private subnets, with a security group that only accepts connections from the app. Then store its connection string and your other secrets:
aws secretsmanager create-secret --name api/DATABASE_URL \ --secret-string "postgresql://USER:PASSWORD@HOST:5432/app" - 4
Deploy the service
Create an ECS Express Mode service from the image, with its secrets referenced from Secrets Manager, and it returns a URL once the service is healthy. Express Mode defaults to 1 vCPU and 2 GB, which is about $36 a month on its own, so pick a smaller size if the app doesn't need that much. For later deploys, the
aws-actions/amazon-ecs-deploy-express-serviceGitHub Action pushes each new image. - 5
Replicate your data
Logical replication copies the data while the Railway app keeps serving. RDS pulls changes from Railway, so turn on public access for the Railway database for the length of the move, and give the RDS subnets a route out through a NAT gateway. Then switch Railway's Postgres to logical replication and restart it from the dashboard:
psql "$DATABASE_PUBLIC_URL" -c "ALTER SYSTEM SET wal_level = logical;"Run the rest from somewhere inside the VPC, such as a CloudShell VPC environment in a private subnet. Copy the schema, publish the tables on Railway and subscribe to them from RDS:
pg_dump "$DATABASE_PUBLIC_URL" --schema-only --no-owner | psql "$RDS_URL" # Postgres rejects updates and deletes on a published table that has no # primary key or other replica identity, so give those tables one. psql -X "$DATABASE_PUBLIC_URL" -At -c "SELECT format('ALTER TABLE %I.%I REPLICA IDENTITY FULL;', n.nspname, c.relname) FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind = 'r' AND n.nspname NOT IN ('pg_catalog', 'information_schema') AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE i.indrelid = c.oid AND i.indisprimary);" \ | psql "$DATABASE_PUBLIC_URL" psql "$DATABASE_PUBLIC_URL" -c "CREATE PUBLICATION aws FOR ALL TABLES;" psql "$RDS_URL" -c "CREATE SUBSCRIPTION aws CONNECTION '$DATABASE_PUBLIC_URL' PUBLICATION aws;"The subscription copies the existing rows, then applies each new write as it happens. Schema changes don't replicate, so hold off on migrations until the switch. Files on a volume come out with
railway volume files downloadand go up withaws s3 sync. - 6
Switch over and move the domain
Recreate each cron service as an EventBridge Scheduler schedule that runs an ECS task. Then stop the Railway service so nothing else writes to the old database. The commands below wait until RDS has every write, then copy the sequence values, which replication doesn't carry, and end the subscription:
# Wait until the new database has confirmed every write Railway made until [ "$(psql -X "$DATABASE_PUBLIC_URL" -At -c "SELECT pg_wal_lsn_diff(pg_current_wal_lsn(), flush_lsn) FROM pg_stat_replication WHERE application_name = 'aws';")" = "0" ]; do sleep 2; done psql -X "$DATABASE_PUBLIC_URL" -At -c "SELECT format('SELECT setval(%L, %s, true);', format('%I.%I', schemaname, sequencename), last_value) FROM pg_sequences WHERE last_value IS NOT NULL;" | psql "$RDS_URL" psql "$RDS_URL" -c "DROP SUBSCRIPTION aws;"Request an ACM certificate for your domain, add it to the load balancer and point the DNS record at it. Once traffic has moved over, turn off public access on the Railway database and delete the Railway services and their databases.
What a minimal setup costs
One small app 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
App 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. 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 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 writes one config file, and the deploy creates the rest.
Read the guide to moving from Railway to Modelence, or paste this into your coding agent to start:
Frequently asked questions
What is the AWS equivalent of Railway?
ECS Express Mode is the closest. It turns a container image into a running service with a load balancer, HTTPS, autoscaling and logs. The databases, secrets and scheduled jobs come from separate services: RDS, ElastiCache, Secrets Manager and EventBridge Scheduler.
Can I use AWS App Runner?
Not on a new account. App Runner stopped accepting new customers on April 30, 2026. Existing services keep running, and AWS recommends ECS Express Mode for new ones. The Copilot CLI that many older guides use reached end of support on June 12, 2026.
How much does it cost to run a small app on AWS?
About $45 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 NAT gateway adds about $33 a month per availability zone, and new accounts get up to $200 in credits.
Do I need a NAT gateway?
Not for a simple setup. Tasks can run in public subnets with a public IP, behind a security group that only accepts traffic from the load balancer, which is what Express Mode does by default, while the database stays in private subnets. You need NAT only when the tasks themselves sit in private subnets and call the internet.
How do I move my Postgres database from Railway to RDS?
Use logical replication. Turn on logical replication for the Railway database, copy the schema to RDS, then create a publication on Railway and a subscription on RDS. The subscription copies the existing rows and keeps applying new writes while the Railway app serves, so the only pause is the switch at the end.
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, and keeps them running after the deploy. See the guide to moving from Railway 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