RailwayDocs

railway connect

Connect to a database's interactive shell (psql for Postgres, mongosh for MongoDB, etc.).

Usage

Options

FlagDescription
-e, --environment <ENV>Environment to pull variables from (defaults to linked environment)

Supported databases

DatabaseClient Required
PostgreSQLpsql
MySQLmysql
Redisredis-cli
MongoDBmongosh

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

  1. Detects the database type from the service's image
  2. Fetches connection variables (DATABASE_PUBLIC_URL, REDIS_PUBLIC_URL, etc.)
  3. Launches the appropriate database client with the connection string