Skip to main content

Quick Deploy

Deploy LiteLLM to Railway with one click: Deploy on Railway
1

Click Deploy Button

Click the “Deploy on Railway” button above to open the template.
2

Configure Template

Railway will prompt you to set:
  • Project name
  • Environment variables (API keys)
  • Region preference
3

Deploy

Railway automatically:
  • Creates a new project
  • Provisions PostgreSQL database
  • Builds and deploys LiteLLM
  • Generates a public URL
4

Access Service

Once deployed, Railway provides:
  • Public URL: https://litellm-production.up.railway.app
  • Custom domain: Add your own domain in settings

Manual Railway Deployment

From GitHub Repository

1

Create New Project

  1. Go to Railway Dashboard
  2. Click New Project
  3. Select Deploy from GitHub repo
  4. Choose BerriAI/litellm or your fork
2

Configure Service

Railway auto-detects Docker configuration from the repository.Detected settings:
  • Runtime: Docker
  • Build: Uses /Dockerfile
  • Start command: Automatic from ENTRYPOINT
3

Add PostgreSQL

  1. Click New Service in your project
  2. Select Database → PostgreSQL
  3. Railway provisions database and injects DATABASE_URL
4

Set Environment Variables

Add required variables (see configuration section)
5

Deploy

Railway automatically builds and deploys on push to main branch.

From Docker Image

1

Create New Project

  1. Click New Project
  2. Select Deploy a Docker Image
2

Specify Image

3

Configure Command

Add custom start command:

Database Setup

Railway PostgreSQL

Railway automatically sets DATABASE_URL when you add PostgreSQL to your project.
1

Add Database

  1. In your project, click New
  2. Select Database → PostgreSQL
  3. Railway creates database with:
    • 1GB storage (Hobby plan)
    • Automatic backups
    • Private networking
2

Connection String

Railway automatically injects:
No manual configuration needed!
3

Enable Model Storage

Add to your service:

Database Migrations

Migrations run automatically on container start using Prisma.
First deployment takes 15-20 seconds while Prisma runs migrations and generates the client.

Environment Configuration

Required Variables

In Railway service settings, add:

Provider API Keys

Optional Configuration

Don’t set PORT manually - Railway injects this automatically and maps to your service.

Configuration with config.yaml

Mount Configuration File

1

Create Config in Repo

Add config.yaml to your repository:
config.yaml
2

Update Start Command

In Railway service settings:
3

Redeploy

Push to GitHub or trigger manual deploy in Railway dashboard.

Use Railway Variables

1

Create Variable Groups

Organize variables by environment:
  • production - Live environment
  • staging - Testing environment
  • development - Local development
2

Reference in Config

Custom Domain

1

Generate Railway Domain

Railway automatically provides:
2

Add Custom Domain

  1. In service settings, go to Settings → Networking
  2. Click Add Custom Domain
  3. Enter your domain: api.yourdomain.com
3

Configure DNS

Add a CNAME record:
4

Wait for SSL

Railway automatically provisions SSL certificate (2-5 minutes).
Railway provides automatic SSL for all domains using Let’s Encrypt.

Redis for Caching

Add Redis Service

1

Add Redis to Project

  1. Click New in your project
  2. Select Database → Redis
  3. Railway provisions Redis with:
    • 100MB storage (Hobby plan)
    • Private networking
    • Auto-injected connection details
2

Configure LiteLLM

Railway auto-injects Redis variables:
Or use individual variables:
3

Enable Caching

Update config.yaml:

Private Networking

Railway provides free private networking between services in the same project.
Services can communicate using:

Deployment Strategies

Continuous Deployment

Railway automatically deploys on Git push:
Railway will:
  1. Detect the push via webhook
  2. Build Docker image
  3. Run health checks
  4. Deploy with zero downtime

Manual Deployment

  1. Go to service in Railway dashboard
  2. Click Deploy → Redeploy
  3. Or Trigger Deploy for specific commit

Rollback

1

View Deployments

Click Deployments tab in service dashboard
2

Select Previous Version

Click on successful deployment
3

Rollback

Click Redeploy this version

Monitoring and Observability

Railway Observability

Built-in monitoring includes:
  • Logs: Real-time log streaming
  • Metrics: CPU, Memory, Network, Disk
  • Deployments: Build and deploy history
  • Events: Service lifecycle events

View Logs

Metrics Dashboard

Access in Metrics tab:
  • CPU usage: % utilization over time
  • Memory usage: MB used / available
  • Network: Inbound/outbound traffic
  • Request count: Requests per second

External Monitoring

Add monitoring services:
Add to config.yaml:

Scaling

Vertical Scaling

Upgrade service resources:
  1. Go to Settings → Resources
  2. Select plan:
    • Hobby: 512MB RAM, 0.5 vCPU ($5/month)
    • Pro: 8GB RAM, 8 vCPU ($20/month)

Horizontal Scaling

Railway Hobby plan supports 1 instance only. Upgrade to Pro for multiple instances.
Pro plan features:
  • Multiple service instances
  • Load balancing
  • Zero-downtime deployments
  • Vertical and horizontal scaling

Cost Management

Pricing Overview

Cost Optimization Tips

1

Use Shared Database

Share PostgreSQL between staging/development environments.
2

Remove Unused Services

Delete stopped or unnecessary services to avoid charges.
3

Set Resource Limits

Configure memory and CPU limits to control costs:
4

Use Sleep Mode

Enable auto-sleep for development environments (Hobby plan only).

Troubleshooting

Build Failures

Service Won’t Start

Database Connection Issues

High Memory Usage

Railway CLI

Installation

Common Commands

Comparison: Railway vs Render

Next Steps

Fly.io Deployment

Deploy closer to users with edge compute

Monitoring

Set up observability and alerts

Security

Secure your deployment

Performance

Optimize for production workloads