railway environment
Create, delete, edit, or link an environment.
Usage
railway environment [ENVIRONMENT] [COMMAND]Aliases
railway env
Subcommands
| Subcommand | Aliases | Description |
|---|---|---|
list | ls | List all environments in the project |
link | Link an environment to the current project | |
new | create, add | Create a new environment |
delete | rm, remove | Delete an environment |
edit | update | Edit an environment's configuration |
config | show, info | Show environment configuration |
Examples
Link an environment (interactive)
railway environmentLink a specific environment
railway environment stagingCreate a new environment
railway environment new stagingDuplicate an environment
railway environment new staging --duplicate productionOr using the alias:
railway environment new staging --copy productionDelete an environment
railway environment delete stagingEdit environment configuration
railway environment edit --service-config backend variables.API_KEY.value "secret"Show environment configuration
railway environment configOptions for
| Flag | Description |
|---|---|
-d, --duplicate <ENV> | Environment to duplicate (alias: --copy) |
--json | Output in JSON format |
Options for
| Flag | Description |
|---|---|
-y, --yes | Skip confirmation dialog |
--2fa-code <CODE> | 2FA code for verification |
--json | Output in JSON format |
Options for
| Flag | Description |
|---|---|
-e, --environment <ENV> | Environment to edit |
-s, --service-config <SERVICE> <PATH> <VALUE> | Configure a service using dot-path notation |
-m, --message <MSG> | Commit message for the changes |
--stage | Stage changes without committing |
--json | Output in JSON format |
Dot-path notation for
The --service-config flag uses dot-path notation to specify nested configuration values:
# Set a variable value
railway environment edit --service-config backend variables.API_KEY.value "secret"
# Set a service configuration
railway environment edit --service-config api buildCommand "npm run build"The format is: --service-config <SERVICE_NAME> <DOT.PATH.TO.PROPERTY> <VALUE>
Options for
| Flag | Description |
|---|---|
-e, --environment <ENV> | Environment to show configuration for (defaults to linked environment) |
--json | Output in JSON format |
Config examples
Show configuration for the current environment:
railway environment configShow configuration for a specific environment:
railway environment config --environment stagingOutput as JSON:
railway environment config --json