Hands-on Lab·PostgreSQL
PostgreSQL Connection Limits and PgBouncer
Fill every slot and read the error PostgreSQL actually gives - it is not the one everybody quotes. Then 60 clients through PgBouncer become 5 server backends.
Monitoring and Operations Guide 42 of 47 Intermediate
- OSUbuntu 26.04 LTS (resolute)
- PostgreSQL18.6-0ubuntu0.26.04.1
- Host2 core / 4 GB, 400,000-row test table
- TimeAbout 20 min
- Reviewed27 August 2026
Written against the versions above. `reserved_connections` is separate from `superuser_reserved_connections` and was added in PostgreSQL 16, for members of `pg_use_reserved_connections`. PgBouncer here is 1.25.1.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- A cluster you can restart -
max_connectionsneeds one. - The
appdbdatabase.
-
Count the budget
-
Lower it, and watch the reload not work
-
Fill every slot
-
Limit a role rather than the server
-
Install PgBouncer and point it at the cluster
-
Configure transaction pooling
-
Sixty clients, five backends
-
Put the cluster back