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---2name: railway-deployment3description: Use this skill when deploying to Railway, including environment checks, service configuration, health verification, rollout observation, logs, and rollback readiness.4---56# Railway Deployment78Guide Railway deployments from preflight validation to post-deploy verification.910## When to Use1112- You are preparing to deploy or update an application on Railway.13- You need a repeatable deployment checklist with explicit verification.14- You want to minimize release risk with rollback planning.1516## Workflow17181. **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.19202. **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.21223. **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.23244. **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).25265. **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.27286. **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.29307. **Trigger rollback if checks fail.** Use Railway's deployment history: Dashboard -> Service -> Deployments -> select previous deploy -> Redeploy. Capture incident notes for post-mortem.3132## Common Pitfalls3334- **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.35- **Missing health check endpoint.** Without a health endpoint, Railway cannot detect unhealthy instances; consider adding `/health` or similar for monitoring and load balancer checks.36- **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.37- **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.3839## Railway CLI and Configuration4041```bash42railway login43railway link # Link to existing project44railway up # Deploy from current directory45railway logs # Stream logs46railway run <cmd> # Run command with env vars injected47railway variables # List env vars48```4950Example `railway.json`:5152```json53{54 "$schema": "https://railway.app/railway.schema.json",55 "build": {56 "builder": "NIXPACKS",57 "buildCommand": "npm run build"58 },59 "deploy": {60 "startCommand": "npm run start",61 "healthcheckPath": "/health",62 "healthcheckTimeout": 30,63 "restartPolicyType": "ON_FAILURE",64 "restartPolicyMaxRetries": 365 }66}67```6869Example `Procfile`: `web: npm run start`7071## Rollback and Monitoring7273Railway 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.7475## Output Format7677```markdown78## Deployment Plan79- Target service: <name>80- Change scope: <summary>81- Region: <if applicable>82- Start command: <explicit command>8384## Preflight Checklist85- [ ] Required env vars validated86- [ ] Runtime/build settings confirmed (railway.json or Procfile)87- [ ] Migration risk reviewed88- [ ] Health check endpoint configured89- [ ] Volume mounts configured if needed9091## Commands921. railway up932. railway logs9495## Verification96- [ ] Health endpoint passes97- [ ] Key user flow validated98- [ ] Error rate and logs normal99- [ ] Sleep behavior documented (Starter plan)100101## Rollback102- Trigger: <condition>103- Action: Dashboard -> Deployments -> select prior deploy -> Redeploy104- Notes: <incident capture>105```106107## Constraints108109- Prefer deterministic checklists and explicit pass/fail criteria.110- Do not assume deploy success until verification steps are complete.111- Highlight unknowns instead of guessing environment details.112- Always set startCommand explicitly; do not rely on Nixpacks detection alone.113- Document sleep behavior for Starter plan services.