CLI
The Railway Command Line Interface (CLI) lets you interact with your Railway projects from the command line.
Installing the CLI
Install the Railway CLI with agent support configured in one step (macOS, Linux, Windows via WSL):
curl -fsSL agents.railway.com | shThis installs the CLI to ~/.railway/bin and runs railway setup agent to configure detected agent tools.
To install the CLI without agent configuration:
bash <(curl -fsSL railway.com/install.sh)On Windows, use Windows Subsystem for Linux with a Bash shell.
Other installation methods
Homebrew (macOS)
brew install railwaynpm (macOS, Linux, Windows)
npm i -g @railway/cliRequires Node.js version 16 or higher.
Scoop (Windows)
scoop install railwayPre-built binaries
Download pre-built binaries from the GitHub repository.
From source
Build from source using the instructions in the GitHub repository.
Authentication
Before using the CLI, authenticate with your Railway account:
railway loginFor environments without a browser, such as SSH sessions, use browserless login:
railway login --browserlessTokens
For CI/CD pipelines, set environment variables instead of interactive login:
- Project Token: Set
RAILWAY_TOKENfor project-level actions - Account/Workspace Token: Set
RAILWAY_API_TOKENfor account-level actions
RAILWAY_TOKEN=xxx railway upSee Tokens for more information.
Available commands
Authentication
railway login # Login to Railway
railway login --browserless # Login without browser
railway logout # Logout from Railway
railway whoami # Show current userProject management
railway init # Create a new project
railway link # Link to existing project
railway unlink # Unlink current directory
railway list # List all projects
railway status # Show project info
railway open # Open in browserinit · link · unlink · list · status · open · project
Deployment
railway up # Deploy current directory
railway up --detach # Deploy without streaming logs
railway deploy --template postgres # Deploy a template
railway redeploy # Redeploy latest deployment
railway restart # Restart a service
railway down # Remove latest deployment
railway deployment list # List deployments
railway templates search # Search published templatesup · deploy · redeploy · restart · down · deployment · templates · Deploying Guide
Services
railway add # Add a service (interactive)
railway add --database postgres # Add PostgreSQL
railway add --repo user/repo # Add from GitHub repo
railway service # Link a service
railway service files browse /app # Browse service files in a TUI
railway service files download /app/data.db ./data.db # Download from a service
railway scale # Scale a service
railway delete # Delete a projectadd · service · scale · delete
Variables
railway variable list # List variables
railway variable set KEY=value # Set a variable
railway variable delete KEY # Delete a variableEnvironments
railway environment # Switch environment (interactive)
railway environment new staging # Create new environment
railway environment delete dev # Delete an environmentLocal development
railway run npm start # Run command with Railway env vars
railway shell # Open shell with Railway env vars
railway dev # Run services locally with DockerLogs & debugging
railway logs # Stream deployment logs
railway logs --build # View build logs
railway logs --dns # Stream DNS query logs
railway logs -n 100 # View last 100 lines
railway ssh # SSH into service container
railway connect # Connect to database shell
railway metrics # View resource and HTTP metricslogs · ssh · connect · metrics
Networking
railway domain # Generate Railway domain
railway domain example.com # Add custom domain
railway domain list # List service domains
railway domain status example.com # Show DNS details
railway cdn status # Show CDN caching settings
railway cdn enable # Enable CDN caching
railway cdn purge html # Purge cached HTML
railway waf under-attack status # Show WAF protection status
railway waf under-attack enable # Enable Under Attack Mode
railway outbound-network status # Show outbound networking status
railway outbound-network static-ip enable # Enable Static Outbound IPs
railway outbound-network ipv6 enable # Stage Outbound IPv6
railway private-network status # Show private networking status
railway tcp-proxy create --port 5432 # Create a public TCP proxydomain · cdn · waf · outbound-network · private-network · tcp-proxy
Volumes
railway volume list # List volumes
railway volume add # Add a volume
railway volume browse / # Browse volume files in a TUI
railway volume files download /backup.tar ./backup.tar # Download from a volume
railway volume delete # Delete a volumeBuckets
railway bucket list # List buckets
railway bucket create # Create a bucket
railway bucket info # Show bucket details
railway bucket credentials # Show or reset S3-compatible credentials
railway bucket delete # Delete a bucketFunctions
railway functions list # List functions
railway functions new # Create a function
railway functions push # Push function changesSandboxes
railway sandbox create # Create a sandbox
railway sandbox list # List sandboxes in the environment
railway sandbox ssh # SSH into the active sandbox
railway sandbox exec -- ls -la # Run a command in the active sandbox
railway sandbox destroy # Destroy a sandboxAI & agents
railway agent # Chat with the Railway Agent
railway agent -p "..." # Send a single prompt
railway agent --list # List previous agent threads
railway agent --thread-id <ID> # Resume a previous thread
railway setup agent # Configure Railway agent tooling
railway mcp install # Configure MCP for AI coding tools
railway skills install # Install Railway agent skillsPublic API
railway api 'query { me { id } }' # Execute a GraphQL query
railway api search deployment # Search the API schema
railway api describe Deployment # Describe a type or field
railway api schema # Print the full schemaUtilities
railway completion bash # Generate shell completions
railway docs # Open documentation
railway upgrade # Upgrade CLI
railway autoupdate status # Show auto-update statuscompletion · docs · upgrade · autoupdate · starship
Global options
These flags are available across multiple commands:
| Flag | Description |
|---|---|
-s, --service | Target service (name or ID) |
-e, --environment | Target environment (name or ID) |
--json | Output in JSON format |
-y, --yes | Skip confirmation prompts |
-h, --help | Display help information |
-V, --version | Display CLI version |
See Global Options for more details.
SSH
The Railway CLI enables you to start a shell session inside your deployed Railway services:
railway sshCopy the exact command from the Railway dashboard by right-clicking on a service and selecting "Copy SSH Command".
See railway ssh for more details.
Contributing
The Railway CLI is open source. Contribute to the development of the Railway CLI by opening an issue or Pull Request on the GitHub Repo.