Railway Deployment

Deploy to Railway for managed hosting.

Railway Setup

1. Install Railway CLI

# macOS
brew install railway

# Or using npm
npm install -g @railway/cli

# Login
railway login

# Verify
railway whoami

2. Initialize Project

# Create new project
railway init

# Or link existing
railway link

3. Add Database

Environment Variables

Required Variables

Set these in Railway dashboard (Settings → Variables):

Railway JSON Config

The API service uses a Dockerfile-based deployment and a liveness health check:

/health is a liveness endpoint and returns 200 even while the app is still retrying database startup. Use /ready to confirm the database is connected before sending traffic that depends on PostgreSQL.

Database Setup

1. Create Database

In Railway dashboard:

  1. Go to your project

  2. Click "New" → "Database" → "PostgreSQL"

  3. Note the connection string

2. Initialize the Schema

3. Seed Data (Optional)

Deploy

1. Deploy to Railway

2. View Deployment

3. Verify Deployment

Custom Domain

1. Add Domain

In Railway dashboard:

  1. Go to project → Settings → Domains

  2. Add custom domain (e.g., mutx.dev)

  3. Note the CNAME record

2. Configure DNS

Add CNAME record:

3. SSL

Railway automatically provisions Let's Encrypt SSL.

Multiple Services

For a more complete setup, create multiple Railway services:

Service 1: Frontend (Next.js)

Service 2: API (FastAPI)

Create api/Dockerfile:

Create railway.json for API:

Troubleshooting

Build Failed

Service Not Starting

Database Connection

Custom Domain Not Working

Maintenance

Update Deployment

Rollback

In Railway dashboard:

  1. Go to Deployments

  2. Find previous deployment

  3. Click "Redeploy"

Scale

In Railway dashboard:

  • Go to Settings → Scaling

  • Adjust replicas (max 20 on Pro plan)

Quick Reference

Last updated