PostgreSQL Connection Limit Error
TOC
Problem DescriptionRoot CauseTroubleshootingSolutionPath 1 - Increase PostgreSQL capacityPath 2 - Tune Harbor's DB poolStep 1 - Patch the CR with new valuesStep 2 - Validate that settings took effectStep 3 - Check Harbor runs smoothlyProblem Description
Harbor component logs (for example core, jobservice) show database errors such as:
Root Cause
Harbor opened more concurrent PostgreSQL connections than the database allows (exceeded PostgreSQL max_connections).
Troubleshooting
Check the logs of the Harbor Core Deployment. Confirm if the pq: sorry, too many clients already error message is present.
Solution
You have two modification paths—choose one or both depending on your diagnosis.
Decide whether PG's maximum is too low or Harbor's per-pod pool is too high for your replica count, then adjust the values. After your change, peak Harbor connections remain below PG's limit.
Path 1 - Increase PostgreSQL capacity
If PostgreSQL's max_connections is too low for your Harbor scale, increase it on your PostgreSQL side. The exact steps depend on how you manage PG and are out of scope here.
You can use the following command to check PostgreSQL capacity and current usage:
Path 2 - Tune Harbor's DB pool
If Harbor is opening too many connections, reduce Harbor's pool settings. Remember:
database.maxOpenConnsis applied per Pod (each Harbor component instance); scaling replicas increases total potential connections.- When you change
maxOpenConns, reviewmaxIdleConnsso it remains sensible (commonly ≤maxOpenConns).
Step 1 - Patch the CR with new values
Replace <NAME> with your Harbor CR name and <NAMESPACE> with your Harbor CR namespace.
Replace <MAX_OPEN_CONNS> and <MAX_IDLE_CONNS> with your desired values.
Step 2 - Validate that settings took effect
Check the rendered configuration reflects the new values.
The output should look like this, the value should be the same as you specified in the patch command:
Step 3 - Check Harbor runs smoothly
After your change, peak Harbor connections remain below PG's limit.