NinjaOps Fixes
/
PostgreSQL
PostgreSQL Fixes
7 troubleshooting guides — each with the error, why it happens, and copy-paste commands to fix it.
PostgreSQL: "Deadlock Detected" (40P01) — Ordering and the Retry
— Two transactions each hold locks the other needs; Postgres detects the cycle and kills one (40P01).
PostgreSQL "FATAL: role \"postgres\" does not exist"
— The role you're connecting as was never created on this cluster — a classic after OS-package installs where the superuser is named after your system user, not 'postgres'.
PostgreSQL "Connection Refused" on 5432: Cluster Down or Not Listening
— Refused on 5432 means nothing is accepting there: cluster not running, listening on localhost only, or wrong port.
Postgres Down or Slow: Disk Filled by WAL (pg_wal) — Space Recovery Order
— When pg_wal bloats to a disk-full, Postgres enters a state where nothing works normally.
Postgres "the database system is starting up" — Crash Recovery or Stuck?
— After an unclean shutdown Postgres replays WAL before accepting connections.
PostgreSQL "Duplicate Key Value Violates Unique Constraint"
— An insert collided with a unique index.
PostgreSQL: "password authentication failed for user" (and the peer Trap)
— The credential failed OR pg_hba.