CLI

GIF of the CLI in Action

The Railway command line interface (CLI) connects your code to your Railway project from the command line.

The Railway CLI allows you to

  • Create new Railway projects from the terminal
  • Link to an existing Railway project
  • Pull down environment variables to run your project locally
  • Open an interactive shell to a database within a project

Install

Install with Brew, NPM or Scoop.

Homebrew

NPM

Shell Script

Scoop

Use this method if you prefer to interact with Railway using a native Windows binary. In a PowerShell terminal enter the following command:

For additional documentation on Scoop, see here.

Source

You can also download the prebuilt binary directly or build from source.

Login

Login to your Railway account. Opens a browser tab which authenticates into an existing Railway session.

If there are any issues with Browser based login you can use the --browserless flag to authenticate.

Project Token

You can use Project tokens to authenticate in environments that prevent you to authenticate with browsers such as CI environments.

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 run.

Link to an existing Project under your Railway account or team.

Screenshot of Railway

Create a Project

Create a new project directly from the command line.

Local Development

Run code inside your Railway environment. We connect your code to your infrastructure hosted on Railway by injecting environment variables.

For example, to run your node project with Railway:

If you have a Dockerfile in your project directory, you can just run railway run with no arguments to build and run the Dockerfile.

Local Shell

Open an interactive subshell loaded with your project's environment variables.

Environments

Projects might have multiple environments, by default the CLI points to the production environment. If you'd like to use a different set of environment variables and a different deployment environment you can change the setting by:

Deploy

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 a database service for a project.

Connect to Database

Open an interactive shell to a database directly in the CLI.

Logout

Contributing

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 our documentation of the CLI API here.


Edit this file on GitHub