| name | railway-cli |
| description | Deploy and manage apps on Railway's cloud platform. Use when deploying, checking logs, managing environments, or running commands against Railway services. Use when this capability is needed. |
| metadata | {"author":"dimitri-vs"} |
Railway CLI
Railway CLI for deploying and managing cloud applications.
Full CLI reference: https://docs.railway.com/reference/cli-api
Important Notes
- Monorepo: For commands like
railway up, ensure you are in the correct project subdirectory (e.g., frontend/ or backend/)
- Interactive commands:
railway link, railway service, railway environment are interactive by default. Use flags for non-interactive mode (see below).
- Logs timeout: Always run
railway logs with a 5-second timeout as logs stream indefinitely
- Deployments:
railway up may take up to 3-5 minutes to complete
- JSON output: All commands support
--json flag for scripting
Quick Reference
railway whoami
railway login
railway login --browserless
railway init -n "my-project"
railway status
railway link
railway link -p <project> -e <env> -s <service>
railway unlink
railway list
railway open
railway service
railway service <name>
railway add
railway add -d postgres
railway add -s api -i nginx:latest
railway add -s backend --variables "PORT=3000"
railway up
railway up --detach
railway up --ci
railway down
railway down -y
railway redeploy
railway logs -s <service>
railway logs -d
railway logs -b
railway variables
railway variables --kv
railway variables --set "KEY=value"
railway run -- <command>
railway shell
railway ssh -s <service>
railway ssh -s <service> -- <command>
railway connect
railway environment
railway environment new <name>
railway environment new <name> -d <source>
railway environment delete <name>
railway volume list
railway volume add
railway volume attach
railway volume detach
railway domain
railway domain example.com -p 8080
railway help
railway help <command>
Deployment Workflow
Initial Setup (Interactive)
railway login
railway link
Initial Setup (Non-Interactive / CI)
railway login --browserless
railway link -p myproject -e production -s api
Deploy
railway up --detach
railway up --ci
Check Status
railway status
timeout 5 railway logs -s <service> || true
Configuration Files
railway.json
Important: The config file path does NOT follow Root Directory. In dashboard settings, use absolute path like /backend/railway.json.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "RAILPACK",
"buildCommand": "npm install && npm run build"
},
"deploy": {
"startCommand": "npx serve dist -l $PORT",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
Railpack Environment Variables
Railpack is the new default builder (Nixpacks is legacy). Configure with env vars:
| Variable | Description |
|---|
RAILPACK_PACKAGES | Mise packages to install |
RAILPACK_BUILD_APT_PACKAGES | Apt packages for build |
RAILPACK_DEPLOY_APT_PACKAGES | Apt packages in final image |
RAILPACK_INSTALL_COMMAND | Override install command |
See Railpack docs for full options.
Monorepo Setup
- Go to Railway Dashboard > Service > Settings
- Set Root Directory to
/frontend or /backend
- Set Railway Config File to absolute path:
/frontend/railway.json
- Set Watch Paths using absolute paths:
/frontend/**
Running One-off Commands
Using railway run (local command with Railway env vars)
railway run --service=backend -- python script.py
Using railway shell (subshell with env vars)
railway shell -s <service>
Using railway ssh (run inside container)
railway ssh -s <service> -- ls -la /
railway ssh -s <service> -- python /app/scripts/some_script.py
Troubleshooting
- "No start command found": Check Root Directory setting in dashboard
- Port issues: Vite/React apps need
$PORT environment variable
- Environment variables: Prefix with
VITE_ for build-time availability in Vite apps
- Variables syntax: Use
railway variables --set "KEY=value" (not railway variables set)
Dashboard Settings Reference (as of 2026-01-22)
The Service > Settings page in the Railway dashboard has these sections:
Source
- Source Repo: Connected GitHub repo with disconnect option
- Root Directory: Subdirectory for build/deploy (important for monorepos)
- Branch: Which branch triggers deployments for this environment
- Wait for CI: Option to wait for GitHub Actions before deploying
Networking
- Public Networking:
- Railway-generated domain (
*.up.railway.app) with port configuration
- Custom domains with proxy detection
- Target port setting for each domain
- Private Networking:
- Internal hostname (
<service>.railway.internal) for service-to-service communication
- Can also use short name (
<service>) within the project
- Static Outbound IPs: Optional permanent IP for outbound traffic
Build
- Builder: Railpack (new default) or Nixpacks (legacy). Configure via env vars or
railpack.json
- Metal Build Environment: Faster builds (becoming default)
- Providers: Auto-detected language (Python, Node, etc.)
- Custom Build Command: Override default build command (follows Root Directory)
- Watch Paths: Gitignore-style patterns to trigger deploys on specific path changes
- Note: Patterns always operate from repo root
/, even with a Root Directory set. For root directory /app, use /app/**/*.js to match files.
Deploy
- Custom Start Command: Command to run the service
- Pre-deploy Command: Runs before the main service starts (e.g., migrations)
- Regions: Select deployment regions and replica count
- Teardown: Configure old deployment termination behavior
- Resource Limits: CPU (up to 32 vCPU) and Memory (up to 32 GB) per replica
- Cron Schedule: Run service on a cron schedule
- Healthcheck Path: Endpoint to verify deployment is live before completing
- Serverless: Scale to zero when idle, wake on traffic
- Restart Policy: What to do on process exit (Never, Always, On Failure with retry count)
Config-as-code
- Railway Config File: Path to
railway.json or railway.toml for version-controlled settings
- Note: Does NOT follow Root Directory. Use absolute path like
/backend/railway.toml
Root Directory Behavior
When a Root Directory is set, these settings follow it:
- Build command, start command, pre-deploy command
These do NOT follow Root Directory (always use absolute paths from repo root):
- Watch Paths: Use
/app/**/*.js not **/*.js for root dir /app
- Railway Config File: Use
/backend/railway.toml not railway.toml
Storage Buckets
Railway provides S3-compatible object storage ("Buckets") as a first-party service.
- Pricing: $0.015/GB-month storage. Egress and API calls are free (unlimited).
- Access: Private-only (no public URLs). Use presigned URLs or serve through your app.
- S3 compatibility: Full — works with boto3, AWS SDK, any S3 client. Set
endpoint_url to the bucket endpoint.
- Setup: Dashboard > Add > Storage Bucket. Credentials (endpoint, access key, secret, bucket name) are injected as env vars into linked services.
- Limits: No documented caps on object count or request rate. Billed per storage used.
- Compared to alternatives: Same storage price as Cloudflare R2, cheaper than AWS S3 ($0.023/GB). Unlike R2, no per-operation charges. Unlike S3, no egress fees.
Danger Zone
- Delete Service: Permanently removes service and all deployments from the environment
Converted and distributed by TomeVault — claim your Tome and manage your conversions.