railway run
Execute a command locally with environment variables from your Railway service injected.
Usage
railway run [OPTIONS] <COMMAND> [ARGS...]Aliases
railway local
Options
| Flag | Description |
|---|---|
-s, --service <SERVICE> | Service to pull variables from (defaults to linked service) |
-e, --environment <ENV> | Environment to pull variables from (defaults to linked environment) |
-p, --project <ID> | Project ID to use (defaults to linked project) |
--no-local | Skip local develop overrides |
-v, --verbose | Show verbose domain replacement info |
Examples
Run a Node.js app
railway run npm startRun a Python script
railway run python main.pyRun with specific service variables
railway run --service backend npm startRun database migrations
railway run npx prisma migrate deployAccess a repl
railway run rails console
railway run pythonHow it works
- Fetches environment variables from the specified Railway service
- Injects them into the command's environment
- Executes the command
This is useful for:
- Running your app locally with production/staging variables
- Running database migrations
- Accessing REPLs with the correct environment
Exit codes
The command exits with the same code as the executed command.