Railway Deployment
Guide Railway deployments from preflight validation to post-deploy verification.
When to Use
- You are preparing to deploy or update an application on Railway.
- You need a repeatable deployment checklist with explicit verification.
- You want to minimize release risk with rollback planning.
Workflow
Confirm deployment target and intended version/change scope. Identify the project and service(s). Choose deployment region (e.g., US West, EU) if relevant. Note whether this is a new deploy or an update.
Validate runtime and configuration. Use railway.json or Procfile to define build and start commands explicitly; do not rely on Nixpacks guessing. Example railway.json: {"build": {"builder": "NIXPACKS"}, "deploy": {"startCommand": "npm run start", "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 3}}. For databases, ensure TCP proxy is enabled if connecting from external clients; Railway exposes DATABASE_URL with internal hostnames.
Configure volume mounts and environment groups. If the app needs persistent storage, add a volume and mount path in the Railway dashboard. Use environment variable groups to separate staging from production. Reference variables with $VAR syntax in railway.json or dashboard.
Identify risky changes. Review schema migrations, breaking env changes, and external API dependencies. Plan migration order (e.g., run migrations before deploy or use backward-compatible migrations).
Define verification plan. Ensure a health check endpoint exists and returns 200. Railway does not require a health check path for basic deploys, but configuring one improves reliability. Plan checks for critical user flows and error rate.
Execute deploy and monitor. Use railway up or connect a GitHub repo for automatic deploys. Watch build and deploy logs in the dashboard or via railway logs. On Starter plan, services may sleep after inactivity; document this behavior.
Trigger rollback if checks fail. Use Railway's deployment history: Dashboard -> Service -> Deployments -> select previous deploy -> Redeploy. Capture incident notes for post-mortem.
Common Pitfalls
- Not setting start command. Nixpacks may guess incorrectly (e.g., wrong entry point or missing flags). Always set
startCommand in railway.json, Procfile, or dashboard.
- Missing health check endpoint. Without a health endpoint, Railway cannot detect unhealthy instances; consider adding
/health or similar for monitoring and load balancer checks.
- Ignoring Railway sleep on Starter plan. Services sleep after inactivity; first requests after sleep can be slow. Use a paid plan or external cron to keep services warm for production.
- Database connection pooling with serverless. If using serverless runtimes (e.g., serverless functions), connection pooling can exhaust database connections. Use connection poolers (e.g., PgBouncer) or serverless-friendly drivers.
Railway CLI and Configuration
railway login
railway link # Link to existing project
railway up # Deploy from current directory
railway logs # Stream logs
railway run <cmd> # Run command with env vars injected
railway variables # List env vars
Example railway.json:
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS",
"buildCommand": "npm run build"
},
"deploy": {
"startCommand": "npm run start",
"healthcheckPath": "/health",
"healthcheckTimeout": 30,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 3
}
}
Example Procfile: web: npm run start
Rollback and Monitoring
Railway stores deployment history per service. Rollback: Dashboard -> select service -> Deployments -> choose previous successful deploy -> Redeploy. Use railway logs for real-time debugging. Integrate with external monitoring (e.g., Sentry, Datadog) for error tracking and performance.
Output Format
## Deployment Plan
- Target service: <name>
- Change scope: <summary>
- Region: <if applicable>
- Start command: <explicit command>
## Preflight Checklist
- [ ] Required env vars validated
- [ ] Runtime/build settings confirmed (railway.json or Procfile)
- [ ] Migration risk reviewed
- [ ] Health check endpoint configured
- [ ] Volume mounts configured if needed
## Commands
1. railway up
2. railway logs
## Verification
- [ ] Health endpoint passes
- [ ] Key user flow validated
- [ ] Error rate and logs normal
- [ ] Sleep behavior documented (Starter plan)
## Rollback
- Trigger: <condition>
- Action: Dashboard -> Deployments -> select prior deploy -> Redeploy
- Notes: <incident capture>
Constraints
- Prefer deterministic checklists and explicit pass/fail criteria.
- Do not assume deploy success until verification steps are complete.
- Highlight unknowns instead of guessing environment details.
- Always set startCommand explicitly; do not rely on Nixpacks detection alone.
- Document sleep behavior for Starter plan services.
1---2id: railway-deployment3name: railway-deployment4description: Use this skill when deploying to Railway, including environment checks, service configuration, health verification, rollout observation, logs, and rollback readiness.5category: DevOps6---78# Railway Deployment910Guide Railway deployments from preflight validation to post-deploy verification.1112## When to Use1314- You are preparing to deploy or update an application on Railway.15- You need a repeatable deployment checklist with explicit verification.16- You want to minimize release risk with rollback planning.1718## Workflow19201. **Confirm deployment target and intended version/change scope.** Identify the project and service(s). Choose deployment region (e.g., US West, EU) if relevant. Note whether this is a new deploy or an update.21222. **Validate runtime and configuration.** Use `railway.json` or `Procfile` to define build and start commands explicitly; do not rely on Nixpacks guessing. Example `railway.json`: `{"build": {"builder": "NIXPACKS"}, "deploy": {"startCommand": "npm run start", "restartPolicyType": "ON_FAILURE", "restartPolicyMaxRetries": 3}}`. For databases, ensure TCP proxy is enabled if connecting from external clients; Railway exposes `DATABASE_URL` with internal hostnames.23243. **Configure volume mounts and environment groups.** If the app needs persistent storage, add a volume and mount path in the Railway dashboard. Use environment variable groups to separate staging from production. Reference variables with `$VAR` syntax in `railway.json` or dashboard.25264. **Identify risky changes.** Review schema migrations, breaking env changes, and external API dependencies. Plan migration order (e.g., run migrations before deploy or use backward-compatible migrations).27285. **Define verification plan.** Ensure a health check endpoint exists and returns 200. Railway does not require a health check path for basic deploys, but configuring one improves reliability. Plan checks for critical user flows and error rate.29306. **Execute deploy and monitor.** Use `railway up` or connect a GitHub repo for automatic deploys. Watch build and deploy logs in the dashboard or via `railway logs`. On Starter plan, services may sleep after inactivity; document this behavior.31327. **Trigger rollback if checks fail.** Use Railway's deployment history: Dashboard -> Service -> Deployments -> select previous deploy -> Redeploy. Capture incident notes for post-mortem.3334## Common Pitfalls3536- **Not setting start command.** Nixpacks may guess incorrectly (e.g., wrong entry point or missing flags). Always set `startCommand` in `railway.json`, `Procfile`, or dashboard.37- **Missing health check endpoint.** Without a health endpoint, Railway cannot detect unhealthy instances; consider adding `/health` or similar for monitoring and load balancer checks.38- **Ignoring Railway sleep on Starter plan.** Services sleep after inactivity; first requests after sleep can be slow. Use a paid plan or external cron to keep services warm for production.39- **Database connection pooling with serverless.** If using serverless runtimes (e.g., serverless functions), connection pooling can exhaust database connections. Use connection poolers (e.g., PgBouncer) or serverless-friendly drivers.4041## Railway CLI and Configuration4243```bash44railway login45railway link # Link to existing project46railway up # Deploy from current directory47railway logs # Stream logs48railway run <cmd> # Run command with env vars injected49railway variables # List env vars50```5152Example `railway.json`:5354```json55{56 "$schema": "https://railway.app/railway.schema.json",57 "build": {58 "builder": "NIXPACKS",59 "buildCommand": "npm run build"60 },61 "deploy": {62 "startCommand": "npm run start",63 "healthcheckPath": "/health",64 "healthcheckTimeout": 30,65 "restartPolicyType": "ON_FAILURE",66 "restartPolicyMaxRetries": 367 }68}69```7071Example `Procfile`: `web: npm run start`7273## Rollback and Monitoring7475Railway stores deployment history per service. Rollback: Dashboard -> select service -> Deployments -> choose previous successful deploy -> Redeploy. Use `railway logs` for real-time debugging. Integrate with external monitoring (e.g., Sentry, Datadog) for error tracking and performance.7677## Output Format7879```markdown80## Deployment Plan81- Target service: <name>82- Change scope: <summary>83- Region: <if applicable>84- Start command: <explicit command>8586## Preflight Checklist87- [ ] Required env vars validated88- [ ] Runtime/build settings confirmed (railway.json or Procfile)89- [ ] Migration risk reviewed90- [ ] Health check endpoint configured91- [ ] Volume mounts configured if needed9293## Commands941. railway up952. railway logs9697## Verification98- [ ] Health endpoint passes99- [ ] Key user flow validated100- [ ] Error rate and logs normal101- [ ] Sleep behavior documented (Starter plan)102103## Rollback104- Trigger: <condition>105- Action: Dashboard -> Deployments -> select prior deploy -> Redeploy106- Notes: <incident capture>107```108109## Constraints110111- Prefer deterministic checklists and explicit pass/fail criteria.112- Do not assume deploy success until verification steps are complete.113- Highlight unknowns instead of guessing environment details.114- Always set startCommand explicitly; do not rely on Nixpacks detection alone.115- Document sleep behavior for Starter plan services.