Nov 16, 20267 min read

Heroku vs Railway: Which Platform for Your Backend in 2026

How Heroku's dynos and add-ons compare with Railway's usage-based services on pricing, databases, workers, cron and platform direction, and when to run the backend in your own cloud.

Illustration for Heroku vs Railway: Which Platform for Your Backend in 2026

Heroku and Railway both turn a repository into a running service with a database next to it, and both are where developers go when they do not want to learn AWS for a side project or an early product. Heroku prices per dyno and per add-on plan and has been in sustaining engineering since February 2026, while Railway bills CPU and memory per second, deploys databases as services on volumes in the same project canvas and keeps shipping features.

This guide compares the two for backend work, on pricing, databases, workers and cron, and covers when the better answer is a backend in your own AWS or GCP account with Encore.

Heroku vs Railway at a glance

EncoreHerokuRailway
Pricing modelCloud resources billed by AWS or GCPFixed price per dyno and add-on planPlan fee with included usage, then per-second CPU, memory and disk
Entry priceYour cloud billEco $5, Basic $7 per dynoHobby $5 with $5 of usage
PostgresRDS or Cloud SQL in your accountHeroku Postgres add-on, Essential from $5Postgres service on a volume, billed as usage
Background workPub/Sub subscriptions in codeWorker dynosAdditional services
CronCron jobs in code, managed by EncoreHeroku Scheduler, best effortCron schedule on a service, 5-minute minimum, UTC
Local environmentencore run with Postgres and Pub/SubHeroku Local plus your own Postgresrailway run against remote variables
Platform directionActive developmentSustaining engineering since Feb 2026Active development
Where it runsYour own AWS or GCP accountHeroku's infrastructureRailway's infrastructure

Heroku prices are from heroku.com/pricing and Railway prices from railway.com/pricing, checked November 16, 2026.

Running the backend in your own cloud with Encore

Encore

Encore is a backend framework with built-in infrastructure for Go and TypeScript, and the pieces a Heroku or Railway project spreads across dynos, services and add-ons become declarations in the code. On push they are provisioned in your own AWS or GCP account, so the workflow stays close to a PaaS while the database and queues live in your cloud.

Set up the app

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

~
$ encore app create shop --example=hello-world$ cd shop && mkdir -p orders/migrations

The orders service stores orders in Postgres, hands receipts to a subscriber the way a worker dyno or a second Railway service would, and logs the previous day's sales every morning:

-- orders/migrations/1_create_orders.up.sql CREATE TABLE orders ( id BIGSERIAL PRIMARY KEY, idempotency_key TEXT NOT NULL UNIQUE, email TEXT NOT NULL, total_cents BIGINT NOT NULL CHECK (total_cents > 0), created_at TIMESTAMPTZ NOT NULL DEFAULT now(), receipt_sent_at TIMESTAMPTZ, event_published BOOLEAN NOT NULL DEFAULT false );
// orders/orders.go package orders import ( "context" "strings" "encore.dev/beta/errs" "encore.dev/cron" "encore.dev/pubsub" "encore.dev/rlog" "encore.dev/storage/sqldb" ) // Replaces the Railway Postgres service: RDS or Cloud SQL in your account. var db = sqldb.NewDatabase("orders", sqldb.DatabaseConfig{Migrations: "./migrations"}) type OrderPlaced struct { OrderID int64 `json:"order_id"` Email string `json:"email"` } // Replaces the second Railway service that ran a worker loop. var Placed = pubsub.NewTopic[*OrderPlaced]("order-placed", pubsub.TopicConfig{ DeliveryGuarantee: pubsub.AtLeastOnce, }) type PlaceParams struct { IdempotencyKey string `json:"idempotency_key"` Email string `json:"email"` TotalCents int64 `json:"total_cents"` } type PlaceResponse struct { ID int64 `json:"id"` } //encore:api public method=POST path=/orders func Place(ctx context.Context, p *PlaceParams) (*PlaceResponse, error) { if p.IdempotencyKey == "" || !strings.Contains(p.Email, "@") || p.TotalCents <= 0 { return nil, &errs.Error{Code: errs.InvalidArgument, Message: "idempotency key, email and a positive total are required"} } var id int64 var published bool err := db.QueryRow(ctx, ` INSERT INTO orders (idempotency_key, email, total_cents) VALUES ($1, $2, $3) ON CONFLICT (idempotency_key) DO UPDATE SET email = orders.email RETURNING id, event_published`, p.IdempotencyKey, p.Email, p.TotalCents).Scan(&id, &published) if err != nil { return nil, err } if !published { if _, err := Placed.Publish(ctx, &OrderPlaced{OrderID: id, Email: p.Email}); err != nil { return nil, err } if _, err := db.Exec(ctx, ` UPDATE orders SET event_published = TRUE WHERE id = $1 AND event_published = FALSE`, id); err != nil { return nil, err } } return &PlaceResponse{ID: id}, nil } var _ = pubsub.NewSubscription(Placed, "send-receipt", pubsub.SubscriptionConfig[*OrderPlaced]{ Handler: func(ctx context.Context, ev *OrderPlaced) error { // Claim the receipt so a redelivery does not send a second one. res, err := db.Exec(ctx, `UPDATE orders SET receipt_sent_at = now() WHERE id = $1 AND receipt_sent_at IS NULL`, ev.OrderID) if err != nil || res.RowsAffected() == 0 { return err } rlog.Info("send receipt", "order", ev.OrderID, "email", ev.Email) return nil }, }) // Replaces a Railway cron service: called by the Encore platform at 06:00 UTC. var _ = cron.NewJob("daily-sales", cron.JobConfig{ Title: "Log yesterday's sales", Schedule: "0 6 * * *", Endpoint: DailySales, }) type Sales struct { Orders int `json:"orders"` TotalCents int64 `json:"total_cents"` } //encore:api private func DailySales(ctx context.Context) (*Sales, error) { var s Sales err := db.QueryRow(ctx, ` SELECT count(*), coalesce(sum(total_cents), 0) FROM orders WHERE created_at >= date_trunc('day', now()) - interval '1 day' AND created_at < date_trunc('day', now())`).Scan(&s.Orders, &s.TotalCents) if err != nil { return nil, err } rlog.Info("daily sales", "orders", s.Orders, "total_cents", s.TotalCents) return &s, nil }

encore run starts Postgres locally, applies the migration and runs the topic and subscriber in the same process, so the API and the worker run together on a laptop with no Procfile and no remote variables. The receipt claim is a conditional UPDATE, so a message delivered twice sends one receipt. The cron job does not run locally or in preview environments, and you call DailySales from the local development dashboard to check it.

On push, Encore builds the image and provisions the service on Fargate, RDS for PostgreSQL and SNS/SQS in your AWS account, or the GCP equivalents, as the AWS infrastructure docs describe, and cron jobs are managed by the Encore platform with no extra cloud resource, and your cloud provider bills the resources directly. For an AI coding agent the worker and the schedule are code in the same package as the endpoint, so adding a second subscriber or changing the schedule is one reviewed diff that encore run can exercise first.

Best fit: teams outgrowing Heroku or Railway who want a push-to-deploy backend with Postgres, queues and schedules in their own AWS or GCP account.

Heroku: fixed prices and add-ons

Heroku runs processes from a Procfile on dynos, with Eco at $5 per month (sleeps after 30 minutes of inactivity), Basic at $7 always on, and Standard-1X and Standard-2X at $25 and $50 with horizontal scaling and preboot. Heroku Postgres is an add-on with its own plans, from Essential-0 at $5 with 1 GB of storage and 20 connections to Standard-0 at $50 with 4 GB of RAM, and Heroku Key-Value Store and Heroku Scheduler cover caching and periodic jobs. Scheduler runs one-off dynos every 10 minutes, hourly or daily on a best-effort basis, so critical jobs often move to a clock process instead.

From February 2026, Heroku has focused on stability, security and support rather than new features, and it no longer sells Enterprise contracts to new customers, while credit-card accounts keep their pricing and service, and analysts quoted by InfoWorld advise against new strategic development on the platform.

Best fit: existing Heroku apps that run fine today, especially ones tied to Salesforce through Heroku Connect.

Railway: per-second usage and a project canvas

Railway bills a plan fee that includes usage, $5 on Hobby and $20 per workspace on Pro with unlimited seats, and then CPU at about $20 per vCPU-month, memory at about $10 per GB-month, volumes at $0.15 per GB-month and egress at $0.05 per GB, all metered per second. Postgres, Redis and other databases deploy as services with volumes in the project, next to the app, and private networking connects them. Hobby allows up to 6 replicas and 50 services per project, and Pro raises that to 42 replicas.

A Railway cron job is a service with a cron schedule in its settings. Railway starts it in UTC, runs must be at least 5 minutes apart, the process has to exit when it is done, and if the previous run is still active the next one is skipped. Workers are additional services in the same project that share variables.

Best fit: side projects and early products with uneven traffic that benefit from per-second billing and a visual project canvas.

How to choose

Stay on Heroku if the app is stable on its add-ons and the cost of moving is higher than the risk of a platform in sustaining engineering. Pick Railway for usage-based billing that suits idle or spiky services and a fast setup for databases next to the app. Pick Encore when you want the backend's database, queues and schedules declared in code, running locally with encore run and provisioned in your own AWS or GCP account, with your cloud provider billing the resources.

Frequently asked questions

What is the difference between Heroku and Railway?

Heroku charges a fixed monthly price per dyno and per add-on plan, such as $7 for a Basic dyno and $5 for Heroku Postgres Essential-0. Railway charges a plan fee that includes usage credit, $5 on Hobby and $20 per workspace on Pro, then bills CPU, memory and volumes per second. Heroku has been in sustaining engineering since February 2026, while Railway is under active development.

Is Railway cheaper than Heroku?

For services that are idle much of the time, usually yes, since Railway bills actual CPU and memory per second at about $20 per vCPU and $10 per GB of memory per month. For a busy always-on service the per-second usage can end up above a fixed dyno price, so compare against your real resource usage. Prices checked November 16, 2026.

How do cron jobs work on Railway compared with Heroku Scheduler?

A Railway cron job is a service with a cron schedule in its settings; Railway starts it on schedule in UTC, runs must be at least 5 minutes apart, and a run is skipped if the previous one has not exited. Heroku Scheduler is an add-on that starts one-off dynos every 10 minutes, hourly or daily on a best-effort basis.

How do I run a Heroku or Railway style backend in my own AWS account?

With Encore, declare the API endpoints, the Postgres database with sqldb.NewDatabase, the worker as a pubsub.NewSubscription and the schedule as a cron.NewJob in Go or TypeScript, then git push to an environment connected to your AWS account. Encore provisions Fargate, RDS and SNS/SQS there, and cron jobs are managed by the Encore platform.

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.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders