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
Options
| Flag | Description |
|---|---|
-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) |
--json | Output in JSON format |
Examples
Interactive linking
Prompts you to select a workspace, project, environment, and optionally a service.
Link to specific project
Link to specific environment
Link to specific service
Non-interactive (CI/CD)
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)