Railway is a modern PaaS that makes deploying OpenClaw effortless. With built-in CI/CD, automatic HTTPS, and one-click PostgreSQL, you can have a production-ready OpenClaw instance running in minutes. This guide covers everything from initial deployment to custom domains and zero-downtime updates.
Why This Is Hard to Do Yourself
These are the common pitfalls that trip people up.
Cost management
Railway charges by resource usage. Without limits, OpenClaw can rack up unexpected bills.
Ephemeral storage
Railway containers have ephemeral filesystems. Data persistence requires volumes or external storage.
Environment secrets
Managing API keys and secrets across deployments requires proper Railway environment configuration.
Network configuration
Configuring custom domains, HTTPS, and websocket connections requires understanding Railway proxies.
Step-by-Step Guide
Create a new Railway project
Set up your Railway project and connect your GitHub repository.
# Install Railway CLI
npm install -g @railway/cli
# Login to Railway
railway login
# Create new project
railway init
# Select: "Empty Project"
# Name: openclaw-productionAdd PostgreSQL database (if needed)
Add managed PostgreSQL for OpenClaw data persistence.
# In Railway dashboard:
# 1. Click "New" โ "Database" โ "Add PostgreSQL"
# 2. Railway automatically creates DATABASE_URL env var
# 3. Note the connection details for OpenClaw configurationConfigure environment variables
Set up API keys and OpenClaw configuration.
# In Railway dashboard, go to Variables tab:
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
NODE_ENV=production
OPENCLAW_PORT=3000
# Or via CLI:
railway variables set ANTHROPIC_API_KEY=sk-ant-...
railway variables set OPENAI_API_KEY=sk-...Warning: Never commit API keys to Git. Use Railway environment variables for all secrets.
Create railway.toml configuration
Configure build and deploy settings.
# railway.toml in project root:
[build]
builder = "NIXPACKS"
[deploy]
startCommand = "npm start"
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 10
[[deploy.healthcheckPath]]
path = "/health"Add volume for persistent data
Mount a Railway volume for OpenClaw data persistence.
# In Railway dashboard:
# 1. Go to Settings โ Volumes
# 2. Click "Add Volume"
# 3. Mount path: /app/data
# 4. Size: 5GB (adjust as needed)Deploy OpenClaw
Push to GitHub to trigger Railway deployment.
# Push to GitHub (Railway auto-deploys on push)
git add .
git commit -m "feat: deploy openclaw on railway"
git push origin main
# Or deploy via Railway CLI:
railway up
# Check deployment status:
railway statusAdd custom domain (optional)
Configure custom domain with automatic HTTPS.
# In Railway dashboard:
# 1. Go to Settings โ Domains
# 2. Click "Add Domain"
# 3. Enter your domain: openclaw.yourdomain.com
# 4. Add CNAME record in your DNS:
# CNAME openclaw -> <railway-provided-domain>
# Railway automatically provisions SSL certificateRailway Deployment Getting Complex?
We handle production Railway deployments with monitoring, backups, custom domains, and zero-downtime updates. Get your OpenClaw instance live in hours.
Get matched with a specialist who can help.
Sign Up for Expert Help โ