|Docs

railway environment

Create, delete, edit, or link an environment.

Usage

railway environment [ENVIRONMENT] [COMMAND]

Aliases

  • railway env

Subcommands

SubcommandAliasesDescription
listlsList all environments in the project
linkLink an environment to the current project
newcreate, addCreate a new environment
deleterm, removeDelete an environment
editupdateEdit an environment's configuration
configshow, infoShow environment configuration

Examples

railway environment
railway environment staging

Create a new environment

railway environment new staging

Duplicate an environment

railway environment new staging --duplicate production

Or using the alias:

railway environment new staging --copy production

Delete an environment

railway environment delete staging

Edit environment configuration

railway environment edit --service-config backend variables.API_KEY.value "secret"

Show environment configuration

railway environment config

Options for

FlagDescription
-d, --duplicate <ENV>Environment to duplicate (alias: --copy)
--jsonOutput in JSON format

Options for

FlagDescription
-y, --yesSkip confirmation dialog
--2fa-code <CODE>2FA code for verification
--jsonOutput in JSON format

Options for

FlagDescription
-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
--stageStage changes without committing
--jsonOutput 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

FlagDescription
-e, --environment <ENV>Environment to show configuration for (defaults to linked environment)
--jsonOutput in JSON format

Config examples

Show configuration for the current environment:

railway environment config

Show configuration for a specific environment:

railway environment config --environment staging

Output as JSON:

railway environment config --json