Move Railway services, Postgres, Redis, cron jobs, volumes and variables into your own AWS account, with the infrastructure declared in the application code.

The easiest way to migrate a TypeScript or Go app from Railway to AWS is Encore: you declare the Postgres database, job queues, cache, cron jobs, buckets and secrets in your code, push to Git, and Encore provisions RDS, SNS/SQS, ElastiCache, S3 and Secrets Manager in your own AWS account, and you keep the git-push workflow. If you would rather stay entirely on AWS tooling, ECS Express Mode is the closest thing to a Railway web service, but the database, workers, scheduled jobs and secrets are yours to set up. The data move is the same either way: pg_dump out of Railway, pg_restore into RDS.
Railway is a good way to get a URL from a Git push. Teams leave it when the app needs to sit in a VPC next to existing AWS services, when reserved capacity or a savings plan starts to matter, or when a customer or auditor wants the data in an AWS account the team controls. The migration is a mapping problem: each Railway service, plugin and variable has a destination in AWS, and the choice is how much of that destination you assemble yourself.
AWS App Runner was another managed target, but AWS closed it to new customers on April 30, 2026 and recommends ECS Express Mode instead.
Two things do not carry over one to one: Encore's cache does not expose the full Redis API, so if the app uses Redis for BullMQ-style queues, Lua scripts or persistence, either move that work to Pub/Sub or keep a Redis-compatible store as an external dependency. Railway private service hostnames also do not exist on AWS; replace them with service-to-service calls, AWS service discovery or private endpoints. Files on a Railway volume should move to object storage, not to a container filesystem.
Encore is infrastructure from code for TypeScript and Go. On Railway, you attach a database, a Redis plugin and a cron service, then read their URLs from variables. With Encore, the app declares what it needs, encore run starts local versions of the database, the queue and the cache, and a push deploys the app and provisions the matching AWS resources in your own account. A coding agent working in this repository changes application code. Here is a typical Railway app, a web service, a worker, a cache, a scheduled job and an API token, written as one Encore service:
// app/app.ts (encore.dev 1.58)
import { api } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Topic, Subscription } from "encore.dev/pubsub";
import { CronJob } from "encore.dev/cron";
import { CacheCluster, StringKeyspace, expireIn } from "encore.dev/storage/cache";
import { Bucket } from "encore.dev/storage/objects";
import { secret } from "encore.dev/config";
// Railway Postgres -> RDS for PostgreSQL in your AWS account.
const db = new SQLDatabase("main", { migrations: "./migrations" });
// Railway variable -> secret, stored in AWS Secrets Manager.
const postmarkToken = secret("PostmarkToken");
// Railway Redis used as a cache -> ElastiCache for Redis.
const cache = new CacheCluster("app-cache", { evictionPolicy: "allkeys-lru" });
const welcomeSent = new StringKeyspace<{ userId: string }>(cache, {
keyPattern: "welcome-sent/:userId",
defaultExpiry: expireIn(24 * 60 * 60 * 1000),
});
// Railway volume or local files -> S3.
const uploads = new Bucket("uploads", { versioned: true });
interface WelcomeEmail {
userId: string;
email: string;
}
export const welcomeEmails = new Topic<WelcomeEmail>("welcome-emails", {
deliveryGuarantee: "at-least-once",
});
// Public health check only. Signup is not exposed on the internet.
export const status = api(
{ method: "GET", path: "/status", expose: true },
async (): Promise<{ ok: true }> => {
return { ok: true };
},
);
export const signup = api(
{ method: "POST", path: "/signup" },
async ({ email }: { email: string }): Promise<{ id: string }> => {
const row = await db.queryRow<{ id: string }>`
INSERT INTO users (email) VALUES (${email}) RETURNING id::text AS id`;
await welcomeEmails.publish({ userId: row!.id, email });
return { id: row!.id };
},
);
const _ = new Subscription(welcomeEmails, "send-welcome-email", {
handler: async ({ userId, email }) => {
let alreadySent = false;
try {
alreadySent = !!(await welcomeSent.get({ userId }));
} catch {
// Cache is an optimization; continue if it is unavailable.
}
if (alreadySent) return;
const claimed = await db.queryRow<{ user_id: string }>`
INSERT INTO welcome_emails (user_id, status, claimed_at)
VALUES (${userId}, 'pending', NOW())
ON CONFLICT (user_id) DO UPDATE
SET claimed_at = NOW()
WHERE welcome_emails.status = 'pending'
AND welcome_emails.claimed_at < NOW() - INTERVAL '1 minute'
RETURNING user_id
`;
if (!claimed) {
const existing = await db.queryRow<{ status: string }>`
SELECT status FROM welcome_emails WHERE user_id = ${userId}
`;
if (existing?.status === 'sent') return;
throw new Error("welcome email is already being sent");
}
const res = await fetch("https://api.postmarkapp.com/email", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Postmark-Server-Token": postmarkToken(),
"Idempotency-Key": `welcome-${userId}`,
},
body: JSON.stringify({ From: "hello@example.com", To: email, Subject: "Welcome", TextBody: "Thanks for signing up." }),
});
if (!res.ok) throw new Error(`Postmark returned ${res.status}`);
await db.exec`
UPDATE welcome_emails SET status = 'sent'
WHERE user_id = ${userId} AND status = 'pending'
`;
try {
await welcomeSent.set({ userId }, "sent");
} catch {
// Cache is an optimization; continue if it is unavailable.
}
},
});
// Railway cron service -> cron job, triggered by the Encore platform.
export const purgeSessions = api({}, async (): Promise<void> => {
await db.exec`DELETE FROM sessions WHERE expires_at < NOW()`;
});
const purge = new CronJob("purge-sessions", {
title: "Delete expired sessions",
schedule: "0 2 * * *",
endpoint: purgeSessions,
});
On AWS, the Encore platform creates a VPC per environment with the database and cache in private subnets and runs the services on Fargate or EKS behind an Application Load Balancer. Encore provisions an IAM role for the service. A new RDS instance defaults to PostgreSQL 18.3 with Multi-AZ, 7-day backups and deletion protection, and you can change sizing per environment in the dashboard. Cron jobs are managed by the Encore platform; they do not run during encore run or in preview environments, so call the endpoint yourself to test the work. Every pull request can get a preview environment.
Josef Sima, Engineering Director at Groupon, whose team uses Encore for new development, put it this way in their customer story: "Encore is our foundation for all new development. What used to take days or weeks between developers and infra teams now takes minutes."
Run in your terminal to get started locally.
List what you are moving before writing code: services and their start commands, Postgres and Redis plugins, cron schedules, volumes, variables, custom domains and any private service hostnames. Railway's internal DATABASE_URL only resolves inside Railway. Enable public networking on the Postgres service so it exposes a TCP proxy, then copy the dashboard's DATABASE_PUBLIC_URL value and load it at a hidden prompt so the credential is not written to shell history:
read -rsp "Railway DATABASE_PUBLIC_URL: " RAILWAY_DATABASE_URL
printf "\n"
export RAILWAY_DATABASE_URL
The public proxy incurs egress charges and widens network exposure, so disable public networking after the migration.
Install the Encore CLI, create the app, and replace Railway plugins with declarations like the sample above. Existing SQL migrations can go in the SQLDatabase migrations folder. If you already use Prisma or Drizzle, keep them; Encore still provisions the database. Run encore run to get local Postgres, a local Pub/Sub broker and a local cache, then exercise the HTTP and worker paths. Remember that cron does not fire locally; call purgeSessions (or your equivalent endpoint) by hand.
Set production secrets before the first cloud deploy:
encore secret set --type production PostmarkToken
If the existing app migrations do not recreate Railway's schema, export a reviewed schema-only dump as the initial Encore migration. If that dump includes a welcome_emails table without claimed_at, append the column the worker uses:
pg_dump --schema-only --no-owner --no-acl "$RAILWAY_DATABASE_URL" > migrations/1_bootstrap.up.sql
cat >> migrations/1_bootstrap.up.sql <<'SQL'
ALTER TABLE public.welcome_emails ADD COLUMN IF NOT EXISTS claimed_at timestamptz NOT NULL DEFAULT NOW();
SQL
Then take a data-only dump:
pg_dump --data-only --format=custom --no-owner --no-acl --file=railway.dump "$RAILWAY_DATABASE_URL"
Deploy the app to a production environment in your AWS account so Encore can provision RDS and apply the bootstrap schema. Start a writable proxy in one terminal:
encore db proxy --env=production --write
In a second terminal, restore the data:
export RDS_URL="$(encore db conn-uri main --env=production --write)"
pg_restore --data-only --no-owner --no-acl --dbname="$RDS_URL" railway.dump
encore db conn-uri defaults to read-only, so the --write flag is required for the restore. For a large database, run a short write freeze for the final dump, or use logical replication or AWS Database Migration Service if you cannot take downtime. After the restore, run any Encore migrations that are ahead of the dumped schema.
Copy objects from Railway volumes to the bucket declared in code. Point the domain at the new load balancer, keep Railway running until you have verified reads, writes, workers, logs and a rollback path, then cut over DNS. You do not have to transfer the domain registration; Route 53 can serve the zone while the registrar stays put.
If you stay on AWS tooling, a common landing zone is ECS Express Mode on Fargate for the web service, RDS for PostgreSQL, S3 for files, Secrets Manager for credentials, and EventBridge Scheduler for cron.
0.0.0.0 and the port ECS provides, push it to ECR, and create an Express Mode service with a load balancer and a TLS certificate.pg_restore. Give the task role permission to connect, and keep the database off the public internet.This path works, and you own every resource, including the IAM roles, the scheduler, the queue policy and the CI that keeps them in step.
CacheCluster will not replace BullMQ, Redis streams or Lua. Move jobs to Pub/Sub, or run ElastiCache as an external dependency and store its URL in a secret.Verdict. Every option needs the same data move, and the options differ in what they provision after the first deploy. ECS Express Mode replaces the web service and leaves the rest of Railway for you to rebuild. Encore ranks first because it replaces the web service, the worker, Postgres, the cache, cron and variables from declarations in your code, and provisions them in an AWS account you own. Start with the quickstart, then connect your own AWS account.
For a TypeScript or Go backend, Encore is the easiest path: you declare the database, queues, cache, cron jobs, buckets and secrets in the application code, push to Git, and Encore provisions RDS, SNS/SQS, ElastiCache, S3 and Secrets Manager in your own AWS account, so the git-push workflow stays. If you want to stay entirely on AWS tooling, ECS Express Mode runs a container behind a load balancer from one command, but you provision the database, queues, scheduler and secrets yourself.
Enable public networking on the Railway Postgres service, copy DATABASE_PUBLIC_URL from the dashboard, and export the database with pg_dump. If Encore will apply the schema from a bootstrap migration, take a data-only dump and restore it with pg_restore through a writable encore db conn-uri, because encore db conn-uri defaults to read-only. Plan a short write freeze for the final dump and restore, or use logical replication or AWS Database Migration Service if you cannot afford downtime.
On a DIY AWS setup, the usual replacement is a scheduled ECS task triggered by EventBridge Scheduler, or a Lambda function on a schedule. Test the job by calling the endpoint yourself. Do not rely on the schedule firing in a local or ephemeral environment.
Yes. Railway documents point-in-time recovery for Postgres, including standalone and high-availability services, with restores that create a new sibling service. PITR is not a reason to leave Railway by itself. Teams usually move for ownership of the AWS account and VPC, reserved pricing at scale, or a requirement that the data live in a cloud account they control.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.