railway up, run and variables: Deploy on Railway
railway up deploys the current directory to a Railway service, railway run runs a command with the service's variables injected, and railway variables prints them.
Railway's CLI deploys and runs commands against a linked project. In CI you authenticate with a project token and target a service explicitly.
What it does
railway up uploads the project and triggers a build and deploy on Railway. railway run CMD runs CMD locally with the linked service's environment variables injected (useful for migrations). railway variables lists the variables for the active environment and service.
Common usage
# project token authenticates CI; target a service explicitly
export RAILWAY_TOKEN=xxxxxxxx
railway up --service web --detach
# run a migration with the service's variables injected
railway run --service web npm run migrate
railway variables --service webOptions
| Command / flag | What it does |
|---|---|
| up | Deploy the current directory |
| --detach | Do not stream build logs; return after upload |
| --service <name> | Target a specific service |
| run <cmd> | Run a command with service variables injected |
| variables | List variables for the environment/service |
| RAILWAY_TOKEN | Project token for non-interactive auth |
In CI
Set RAILWAY_TOKEN to a project token so the CLI authenticates without railway login. Pass --service in projects with more than one service; otherwise the CLI cannot pick one non-interactively. Add --detach to up if you do not need streamed logs.
Common errors in CI
"Project Token not found" or "Unauthorized. Please login with railway login" means RAILWAY_TOKEN is unset or invalid. "No service linked ... specify a service" means a multi-service project with no --service. "No project linked" means the token is not scoped to a project.