Key Takeaways
- Railway deploys any backend app — Node, Python, Go, Ruby, or Docker — directly from GitHub with zero server config
- One-click database provisioning for PostgreSQL, MySQL, MongoDB, and Redis — Railway injects the connection URL automatically
- Projects group multiple services (app + database + background worker) visually in one dashboard
- Pricing is usage-based — small projects typically cost $5-20/month
- Railway is the best platform for backends that Vercel can't handle — long-running processes, WebSockets, database servers
What Is Railway?
Railway is a deployment platform that runs full backend applications — persistent servers, databases, background workers, cron jobs. Think of it as Heroku but with a modern UI, faster deploys, and a more sensible pricing model.
While Vercel is frontend-first and optimized for serverless functions, Railway runs real servers that stay up. This makes Railway the right choice for:
- REST APIs and GraphQL servers that need persistent connections
- WebSocket servers
- PostgreSQL, MySQL, or MongoDB databases
- Background job workers
- Full-stack apps where you want app + database in the same project
Railway doesn't require Docker knowledge, doesn't require you to configure Nginx, and doesn't require a cloud provider account. You push code to GitHub and Railway runs it.
Deploy Your First Service
Learn the Core Concepts
Start with the fundamentals before touching tools. Understanding why something was built the way it was makes every tool decision faster and more defensible.
Build Something Real
The fastest way to learn is to build a project that produces a real output — something you can show, share, or deploy. Toy examples teach you the happy path; real projects teach you everything else.
Know the Trade-offs
Every technology choice is a trade-off. The engineers who advance fastest are the ones who can articulate clearly why they chose one approach over another — not just "I used it before."
Go to Production
Development is the easy part. The real learning happens when you deploy, monitor, debug, and scale. Plan for production from day one.
Here's how to deploy a Node.js Express app to Railway.
Step 1: Create your app
mkdir my-api && cd my-api
npm init -y
npm install express
Create index.js:
const express = require('express')
const app = express()
const PORT = process.env.PORT || 3000
app.get('/', (req, res) => {
res.json({ status: 'ok', message: 'Railway is running' })
})
app.listen(PORT, () => console.log(`Server on port ${PORT}`))
Add to package.json: "start": "node index.js"
Push to GitHub.
Step 2: Import on Railway
- Go to railway.app and sign in with GitHub
- Click "New Project" → "Deploy from GitHub repo"
- Select your repo
- Railway detects Node.js and runs
npm startautomatically
Step 3: Get your URL
Click "Settings" → "Networking" → "Generate Domain." Railway gives you a *.railway.app URL pointing to your running app. Every push to main triggers a re-deploy.
Adding a Database
This is one of Railway's best features. Adding a database is genuinely two clicks.
PostgreSQL
- In your Railway project, click "New Service"
- Select "Database" → "PostgreSQL"
- Railway provisions a Postgres instance and adds it to your project
- Click the Postgres service → "Variables" tab → copy the
DATABASE_URL
Railway automatically injects the database environment variables into your app service. You don't need to copy-paste anything — if your app and database are in the same Railway project, the variables are shared automatically.
Running migrations
You can run database migrations as a Railway "Deploy" step. In your service settings, set a custom deploy command:
npm run migrate && npm start
This runs your migration tool (Prisma, Drizzle, Flyway) before starting the app on every deploy.
Environment Variables
Railway handles environment variables in the service settings panel under "Variables." You add key-value pairs and they're injected into your app's process at runtime.
Shared variables
In a Railway project with multiple services, you can create shared variables that are available to all services. This is great for things like a shared secret key or an API URL that multiple services need.
Railway's built-in variables
Railway automatically provides PORT, RAILWAY_ENVIRONMENT, and other platform variables. Your app should use process.env.PORT (not a hardcoded port) so Railway can route traffic correctly.
Custom Domains
Adding a custom domain to a Railway service works the same as most platforms:
- Service settings → "Networking" → "Custom Domain"
- Enter your domain
- Railway gives you a CNAME value to add at your registrar
- SSL is provisioned automatically after DNS propagates
Deploying a Monorepo or Multi-Service App
Railway's project model shines when you have multiple services that work together — a Next.js frontend, a Node.js API, a Postgres database, and a Redis cache.
In Railway, you add each as a separate service inside the same project. They share environment variables, appear in the same dashboard, and Railway shows the connections between them visually.
Root directory setting
For monorepos, you tell each Railway service which subdirectory to build from. In your service settings, set the "Root Directory" to /apps/api or /packages/backend — Railway only builds that path.
Railway Pricing in Practice
Railway uses usage-based pricing. You pay for CPU, memory, and network used by your services.
Real-world costs (approximate, UNVERIFIED, check current pricing):
- Simple API with low traffic: ~$3-8/month
- API + PostgreSQL database: ~$10-20/month
- Full-stack app with multiple services: ~$20-50/month
The Hobby plan ($5/month) gives you $5 of usage credit each month and access to all features. It's enough for small projects and side projects that don't get heavy traffic.
Railway vs Alternatives
Railway vs Render
Both platforms deploy backends and databases without server management. Railway has a more modern UI with visual project graphs. Render has a free tier with persistent services (though they spin down after inactivity). For teams who need everything in one visual dashboard, Railway wins. For solo projects on a tight budget, Render's free tier is attractive.
Railway vs Fly.io
Fly.io runs Docker containers on dedicated VMs globally. It's more powerful and more complex. Railway is easier to use but has less control. If you need specific geographic regions, multi-region failover, or want to run any Docker workload, Fly.io is worth learning. For most apps, Railway's simplicity is the better tradeoff.
Railway vs Heroku
Railway is what Heroku used to be before Salesforce bought it and removed the free tier. Same developer-friendly DX, better UI, lower price. If you used Heroku before, Railway is the obvious migration target.
Railway vs AWS
AWS offers infinite power and infinite complexity. Railway abstracts all of that away. Use Railway until you have a specific reason to need AWS control — most teams with under $50K/month in infrastructure costs never reach that point.
Ship Real Apps at Our AI Bootcamp
We cover full-stack deployment, databases, and AI integration — hands-on over 3 days. No slides-only lectures. You build and deploy real things.
Upcoming bootcamps: Denver • New York City • Dallas • Los Angeles • Chicago
View Dates and EnrollFAQ
Is Railway free?
Railway has a free trial with $5 of usage credit. After that, it's usage-based pricing — you pay for what you use. A small side project typically costs $5-20/month. The Hobby plan ($5/month) gives you $5 of usage credit and a permanent free tier for very low-traffic projects.
Can Railway run a database?
Yes. Railway has one-click deployment for PostgreSQL, MySQL, MongoDB, and Redis. You add a database service to your project, Railway provisions it instantly, and injects the connection URL as an environment variable your app can use.
Railway vs Render — which is better?
Both are excellent platforms for deploying backends. Railway has a nicer project-based UI that groups services together visually. Render has a longer track record and a slightly more predictable free tier. For new projects in 2026, Railway is the slightly more modern choice with better multi-service support.
Does Railway support Docker?
Yes. If your project has a Dockerfile, Railway builds and runs it automatically. You can also deploy from a pre-built Docker image from a registry like Docker Hub or GitHub Container Registry.