|Docs

railway link

Link an existing Railway project to the current directory. Once linked, commands like railway up and railway logs will target this project.

Usage

railway link [OPTIONS]

Options

FlagDescription
-p, --project <ID|NAME>Project to link to
-e, --environment <ID|NAME>Environment to link to
-s, --service <ID|NAME>Service to link to
-w, --workspace <ID|NAME>Workspace to link to
-t, --team <ID|NAME>Team to link to (deprecated, use --workspace)
--jsonOutput in JSON format

Examples

Interactive linking

railway link

Prompts you to select a workspace, project, environment, and optionally a service.

railway link --project my-api
railway link --project my-api --environment staging
railway link --project my-api --service backend

Non-interactive (CI/CD)

railway link --project abc123 --environment def456 --json

How it works

Railway stores the link configuration in a .railway directory in your project root. This file is typically added to .gitignore.

The link includes:

  • Project ID
  • Environment ID
  • Service ID (optional)