| name | railway-cli |
| description | Manage Railway cloud deployments via the Railway CLI. Use when the user wants to deploy, manage services, set variables, view logs, link projects, add databases, configure domains, manage volumes, or perform any Railway platform operation from the terminal. |
Railway CLI
Operate the Railway platform from the command line. Covers the full lifecycle: authentication, project setup, deployment, services, variables, environments, logs, domains, volumes, functions, and local development.
Source of truth: Railway CLI Docs
Handling Missing Installation
Assume railway is installed. If a command fails with "command not found" or similar, install it before retrying:
brew install railway
npm i -g @railway/cli
bash <(curl -fsSL cli.new)
After install, verify with railway --version, then resume the original task.
Self-Discovery
The Railway CLI evolves across versions. When you encounter an unfamiliar subcommand or need to check current flags:
railway --help
railway <command> --help
Always prefer --help output over memorized flags when composing complex commands. This keeps behavior correct even as the CLI updates.
Authentication
railway login
railway login --browserless
railway logout
railway whoami
CI/CD token auth (no interactive login):
RAILWAY_TOKEN — project-scoped actions
RAILWAY_API_TOKEN — account/workspace-scoped actions
RAILWAY_TOKEN=<token> railway up
Project Lifecycle
Create or link
railway init
railway link
railway unlink
Inspect
railway status
railway list
railway open
Deployment
railway up
railway up --detach
railway deploy --template postgres
railway redeploy
railway restart
railway down
Services
railway add
railway add --database postgres
railway add --repo user/repo
railway service
railway scale
railway delete
Variables
railway variable list
railway variable set KEY=value
railway variable set K1=v1 K2=v2
railway variable delete KEY
Environments
railway environment
railway environment new <name>
railway environment delete <name>
Local Development
railway run <cmd>
railway shell
railway dev
railway run is useful for running migrations, seeds, or scripts that need production/staging credentials without .env files.
Logs & Debugging
railway logs
railway logs --build
railway logs -n 100
railway ssh
railway connect
Networking
railway domain
railway domain example.com
Volumes
railway volume list
railway volume add
railway volume delete
Functions
railway functions list
railway functions new
railway functions push
Utilities
railway completion bash
railway docs
railway upgrade
Global Flags
These flags work across most commands:
| Flag | Description |
|---|
-s, --service <name-or-id> | Target a specific service |
-e, --environment <name-or-id> | Target a specific environment |
--json | Output as JSON (useful for scripting) |
-y, --yes | Skip confirmation prompts |
-h, --help | Show help |
-V, --version | Show CLI version |
Common Workflows
First-time project setup
railway login
railway init
railway up
railway domain
railway logs
Add a database to an existing project
railway add --database postgres
railway connect
railway variable list
Deploy with environment targeting
railway environment new staging
railway up -e staging
railway logs -e staging
Run a one-off command with prod vars
railway run -e production npx prisma migrate deploy
Additional Resources
For the full and most current reference, see reference.md or consult: