blumeops/docs/how-to/connect-to-postgres.md
Erich Blume e1cbd1d57d Add how-to guide for connecting to PostgreSQL via psql
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 07:16:16 -08:00

1 KiB

title modified tags
Connect to Postgres 2026-02-14
how-to
database

Connect to Postgres

How to connect to the postgresql cluster as a superuser using psql.

Prerequisites

  • psql installed (brew install libpq on macOS)
  • 1Password CLI (op) installed and signed in
  • Machine on the tailnet (e.g. gilbert)

Connect

PGPASSWORD=$(op read "op://blumeops/postgres/password") psql -h pg.ops.eblu.me -U eblume -d postgres

This connects as the eblume superuser. To connect to a specific database, replace postgres with the database name (e.g. miniflux, teslamate).

Useful Queries

-- List databases
\l

-- List roles
\du

-- Check cluster status (CNPG)
SELECT pg_is_in_recovery();

-- Show active connections
SELECT datname, usename, client_addr, state
FROM pg_stat_activity
WHERE state IS NOT NULL;