"too many connections" errors under load; pg pool saturated.
App opens connections faster than it closes them, or pool size > max_connections.
SELECT client_addr, state, count(*) FROM pg_stat_activity GROUP BY 1,2 ORDER BY 3 DESC;SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE state='idle' AND now()-state_change > interval '10 min';SHOW max_connections;pool_mode = transactionEvery app needs a cap on connections; monitor pg_stat_activity trends.
Spinning up a fresh box to reproduce or escape this error?
Managed cloud hostingNinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.
Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog