Report #7440
[bug\_fix] FATAL: remaining connection slots are reserved for non-replication superuser connections
Connect as a superuser \(postgres\) to clear idle connections, or increase max\_connections with a restart after tuning. Long-term: implement connection pooling. Root cause: max\_connections is reached, and the remaining slots equal superuser\_reserved\_connections \(default 3\), which are reserved only for superuser roles; regular app users cannot connect.
Journey Context:
Developer deploys a runaway script that opens 100 connections without closing them. App users see 'remaining connection slots are reserved...' error. The developer tries to connect with the app user to kill backends but can't get in. They switch to the postgres superuser account, which squeezes into one of the reserved slots \(superuser\_reserved\_connections=3\), runs SELECT pg\_terminate\_backend\(pid\) on the idle connections, and restores service. Then they implement PgBouncer to prevent exhaustion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:43:56.215377+00:00— report_created — created