|Docs

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 | sh

This 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 railway

npm (macOS, Linux, Windows)

npm i -g @railway/cli

Requires Node.js version 16 or higher.

Scoop (Windows)

scoop install railway

Pre-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 login

For environments without a browser, such as SSH sessions, use browserless login:

railway login --browserless

Tokens

For CI/CD pipelines, set environment variables instead of interactive login:

  • Project Token: Set RAILWAY_TOKEN for project-level actions
  • Account/Workspace Token: Set RAILWAY_API_TOKEN for account-level actions
RAILWAY_TOKEN=xxx railway up

See 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 user

login · logout · whoami

Project 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 browser

init · 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 templates

up · 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 project

add · service · scale · delete

Variables

railway variable list           # List variables
railway variable set KEY=value  # Set a variable
railway variable delete KEY     # Delete a variable

variable

Environments

railway environment             # Switch environment (interactive)
railway environment new staging # Create new environment
railway environment delete dev  # Delete an environment

environment

Local 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 Docker

run · shell · dev

Logs & 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 metrics

logs · 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 proxy

domain · 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 volume

volume

Buckets

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 bucket

bucket

Functions

railway functions list          # List functions
railway functions new           # Create a function
railway functions push          # Push function changes

functions

Sandboxes

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 sandbox

sandbox

AI & 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 skills

agent · setup · mcp · skills

Public 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 schema

api

Utilities

railway completion bash         # Generate shell completions
railway docs                    # Open documentation
railway upgrade                 # Upgrade CLI
railway autoupdate status       # Show auto-update status

completion · docs · upgrade · autoupdate · starship

Global options

These flags are available across multiple commands:

FlagDescription
-s, --serviceTarget service (name or ID)
-e, --environmentTarget environment (name or ID)
--jsonOutput in JSON format
-y, --yesSkip confirmation prompts
-h, --helpDisplay help information
-V, --versionDisplay 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 ssh

Copy 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.