Railway CLI
Official CLI for Railway. Deploy apps, manage services, databases, and environment variables.
- Official repo: https://github.com/railwayapp/cli
- Docs: https://docs.railway.app/reference/cli-api
Authentication
railway login # Browser-based login
railway login --browserless # Token-based login
railway whoami # Check current user
Common Commands
Projects
railway init # Create new project
railway link # Link to existing project
railway status # Show current project/environment
railway list # List all projects
Deployments
railway up # Deploy current directory
railway up --detach # Deploy without following logs
railway logs # View service logs
railway logs --follow # Stream logs in real-time
Environment Variables
railway variables # List variables
railway variables set KEY=value
railway variables delete KEY
Services
railway service # Select active service
railway add # Add a new service (database, etc.)
railway domain # Generate a domain for the service
Shell
railway shell # Open shell with Railway env vars loaded
railway run <command> # Run command with Railway env vars
Agent Best Practices
- Use
railway runto execute commands with the project's env vars injected - Check
railway statusto confirm you're linked to the correct project/environment - Use
railway logs --followfor debugging deployment issues - Use
railway variablesto inspect and manage env vars without the dashboard - Deploy with
railway up --detachfor non-blocking deploys
Example Workflows
Deploy and check logs
railway up --detach
railway logs --num 50
Run database migration with Railway env vars
railway run npx prisma migrate deploy