railway connect
Connect to a database's interactive shell (psql for Postgres, mongosh for MongoDB, etc.).
Usage
Options
| Flag | Description |
|---|---|
-e, --environment <ENV> | Environment to pull variables from (defaults to linked environment) |
Supported databases
| Database | Client Required |
|---|---|
| PostgreSQL | psql |
| MySQL | mysql |
| Redis | redis-cli |
| MongoDB | mongosh |
Examples
Connect to database (interactive)
Prompts you to select a database service if multiple exist.
Connect to specific database
Connect to database in specific environment
Requirements
- The database must have a TCP Proxy enabled (public URL)
- The appropriate database client must be installed on your machine
How it works
- Detects the database type from the service's image
- Fetches connection variables (
DATABASE_PUBLIC_URL,REDIS_PUBLIC_URL, etc.) - Launches the appropriate database client with the connection string