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
| 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
railway linkPrompts you to select a workspace, project, environment, and optionally a service.
Link to specific project
railway link --project my-apiLink to specific environment
railway link --project my-api --environment stagingLink to specific service
railway link --project my-api --service backendNon-interactive (CI/CD)
railway link --project abc123 --environment def456 --jsonHow 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)