Using the CLI

The Railway Command Line Interface (CLI) lets you interact with your Railway project from the command line.

GIF of the CLI in Action

Installing the CLI

The Railway CLI can be installed via Homebrew, npm, Scoop, or directly from the source.

Homebrew (macOS)

In a Terminal, enter the following command:

npm (macOS, Linux, Windows)

In a Terminal, enter the following command:

This requires version =>16 of Node.js.

Shell Script (macOS, Linux, Windows via WSL)

In a Terminal, enter the following command:

On Windows, you should use Windows Subsystem for Linux with a Bash shell.

Scoop (Windows)

In a PowerShell terminal, enter the following command:

This installs a native Windows binary (.exe). To learn more about Scoop, see

Pre-built Binaries

We publish pre-built binaries on our GitHub repository that you can download and use directly.

From Source

The Railway CLI is an open source project on GitHub. You can build a binary from source if you wish.

Authenticating with the CLI

Before you can use the Railway CLI, you must authenticate the CLI to your Railway account:

This command opens a new tab in your default browser to the authentication page. Follow the instructions to complete the authentication process.

Manual Login

You can also authenticate manually using a Pairing Code. This can be useful if you're authenticating the CLI inside an environment without a browser (e.g. SSH sessions).

Use the --browserless flag to authenticate manually:

This will print a URL and a Pairing Code to the Terminal, which you can use to authenticate your CLI session. Follow the instructions to complete the authentication process.

Project Tokens

You can use Project Tokens to authenticate in cases where user input/interaction is not possible, such as in CI/CD pipelines.

Project Tokens allow the CLI to access all the environment variables associated with a specific project and environment. Use the token by setting the RAILWAY_TOKEN environment variable and then running railway <command>.

Common Examples of CLI Usage

Below are some of the most commonly used CLI commands. Find a complete list of CLI commands in the CLI API reference page.

To associate a project and environment with your current directory:

Screenshot of Railway

This prompts you to select a team, project, and environment to associate with your current directory. Any future commands will be run against this project and environment.

Associate a service in a project and environment with your current directory:

This links your current directory with the chosen service.

Create a Project

Create a new project directly from the command line.

This prompts you to name your project and select a team to create the project in.

Local Development

Run code locally with the same environment variables as your Railway project.

For example, to run your Node.js project with your remote environment variables:

Local Shell

Open a new shell with Railway environment variables. Similar to railway run but opens a new shell.


Projects might have multiple environments, but by default the CLI links to the production environment. You can change the linked environment with the environment command.


Deploy the linked project directory (if running from a subdirectory, the project root is still deployed).

If there are multiple services within your project, the CLI will prompt you for a service to deploy to.

Add Database Service

Provision database services for a project.

Prompts you to select one or more databases to provision for your project.



Our CLI is open source. Contribute to the development of the Railway CLI by opening an issue or Pull Request on our GitHub Repo.

You can see the full documentation of the CLI API here.

Edit this file on GitHub