---
title: "Pool acquire timeout: a busy pool or a struggling database? | Proofline"
description: "A connection pool timeout means a request waited for a connection and none came back in time."
url: https://proofline.sh/learn/connection-pool-timeout-or-slow-database/
---

[Learning center](/learn/)

# Pool acquire timeout: a busy pool or a struggling database?

A connection pool timeout means a request waited for a connection and none came back in time. That happens when every pooled connection is busy (slow queries, a leak, or a transaction left open) or when the pool cannot open new connections because the database refuses or does not answer. Read the pool's own counts at the moment of the timeout, then read the same sessions from the database side; the pair tells you which one ran out.

Capacity overruns The Proofline team November 23, 2026 6 min read

## The symptom and its causes

HikariCP, the default pool in many Java services, throws this when `getConnection()` waits longer than `connectionTimeout` (30 seconds by default):

```
checkout-pool - Connection is not available, request timed out after 30004ms (total=10, active=10, idle=0, waiting=37)
```

The message text and the four counts come from the pool's source, and the exception carries the pool's last connection failure as its cause when there was one. Other pools report the same situation in their own words: Go's `database/sql` blocks until a connection is returned or the context is cancelled, and counts that wait in `DB.Stats()`. [HikariCP timeout exception](https://raw.githubusercontent.com/brettwooldridge/HikariCP/dev/src/main/java/com/zaxxer/hikari/pool/HikariPool.java) · [HikariCP configuration](https://github.com/brettwooldridge/HikariCP) · [Go database/sql](https://pkg.go.dev/database/sql)

Four causes produce it:

-   **Slow queries hold every connection.** The pool is full of connections that are executing. The database is the bottleneck: locks, a bad plan, saturated storage.
-   **The application holds connections it is not using.** Code borrows a connection and does not return it (a leak), or opens a transaction and then waits on something else, such as an HTTP call to another service.
-   **The pool cannot open connections.** `total` stays below the configured maximum because each new connection fails: the database is at `max_connections`, authentication fails, or the network path drops the connection attempt.
-   **Demand exceeds a healthy pool.** Queries are fast and nothing leaks, but more requests arrive than the pool can serve. That is a sizing and backpressure question, outside this guide.

## Why they look alike

All four end in the same wait and the same exception, and the database's CPU can be flat in three of them. The difference is whether the pool is at its maximum, and what its sessions are doing inside the database.

## Read the pool's counts

The timeout message already carries `total`, `active`, `idle` and `waiting`. For a trend, HikariCP's Micrometer tracker publishes `hikaricp.connections`, `hikaricp.connections.active`, `hikaricp.connections.idle`, `hikaricp.connections.pending`, `hikaricp.connections.max`, `hikaricp.connections.timeout`, and the timers `hikaricp.connections.acquire`, `hikaricp.connections.usage` and `hikaricp.connections.creation`. Exporters may rename them. `usage` is how long the application keeps a connection before returning it, which is the number that separates a slow database from slow application code once you compare it with query time. [HikariCP Micrometer metric names](https://raw.githubusercontent.com/brettwooldridge/HikariCP/dev/src/main/java/com/zaxxer/hikari/metrics/micrometer/MicrometerMetricsTracker.java)

In Go, `DB.Stats()` returns `MaxOpenConnections`, `OpenConnections`, `InUse`, `Idle`, `WaitCount` and `WaitDuration`. A growing `WaitDuration` with `InUse` equal to `MaxOpenConnections` is the same picture as `active` equal to the maximum. [DBStats](https://pkg.go.dev/database/sql)

If HikariCP's `leakDetectionThreshold` is set (it is 0, disabled, by default), the pool logs `Connection leak detection triggered for` with the borrowing thread's stack trace when a connection stays out longer than the threshold. [leakDetectionThreshold](https://github.com/brettwooldridge/HikariCP) · [Leak task source](https://raw.githubusercontent.com/brettwooldridge/HikariCP/dev/src/main/java/com/zaxxer/hikari/pool/ProxyLeakTask.java)

## Read the same sessions from the database

Connect with a role that can see other sessions' details (a superuser or a member of `pg_read_all_stats`; ordinary roles see many columns as null for other roles' sessions) and group the service's sessions by state. The `application_name` filter works only if the service sets it, as the [holders guide](/learn/postgres-who-holds-connections/) describes; otherwise filter on `client_addr`. [pg\_stat\_activity and visibility](https://www.postgresql.org/docs/current/monitoring-stats.html)

```
SELECT state, wait_event_type, wait_event, count(*) AS sessions,
       max(now() - state_change) AS longest_in_state
FROM pg_stat_activity
WHERE application_name = 'checkout'
GROUP BY state, wait_event_type, wait_event
ORDER BY sessions DESC;
```

Then look at the oldest active queries and anything that blocks them. `pg_blocking_pids` returns the process IDs holding the locks a session waits for. [pg\_blocking\_pids](https://www.postgresql.org/docs/current/functions-info.html)

```
SELECT pid, now() - query_start AS running_for, wait_event_type, wait_event,
       pg_blocking_pids(pid) AS blocked_by, left(query, 80) AS query
FROM pg_stat_activity
WHERE state = 'active' AND backend_type = 'client backend'
ORDER BY query_start
LIMIT 20;

SELECT count(*) AS connections, current_setting('max_connections') AS max_connections,
       current_setting('superuser_reserved_connections') AS superuser_reserved
FROM pg_stat_activity
WHERE backend_type = 'client backend';
```

The `state` values that matter here are `active` (executing a query), `idle` (waiting for a new command), and `idle in transaction` (inside a transaction, not executing). A session in `idle` or `idle in transaction` with wait event `ClientRead` is waiting for the client to send something. [pg\_stat\_activity states and wait events](https://www.postgresql.org/docs/current/monitoring-stats.html)

## What each combination means

| Pool | Database sessions from the service | Points to |
| --- | --- | --- |
| active at max, waiting high | Mostly `active`, long running or waiting on `Lock` | The database or a blocking session |
| active at max, waiting high | Mostly `idle in transaction`, `ClientRead` | Application holds transactions open |
| active at max, waiting high | Mostly `idle`, few sessions | Leak in the application |
| total below max | Few sessions; connection count near the limit | Database refuses new sessions |
| total below max | Few sessions; count well below the limit | Connect path or authentication failing |
| active at max, waiting high | `active` but each query short | Demand exceeds the pool |

For the two rows where `total` stays low, read the timeout exception's cause. A PostgreSQL refusal arrives as `FATAL: sorry, too many clients already` or `remaining connection slots are reserved for roles with the SUPERUSER attribute`. A connect timeout or refusal points at the network path. [PostgreSQL refusal messages](https://raw.githubusercontent.com/postgres/postgres/master/src/backend/storage/lmgr/proc.c) · [Reserved slot messages](https://raw.githubusercontent.com/postgres/postgres/master/src/backend/utils/init/postinit.c) · [Refused or timed out?](/learn/connection-refused-vs-timeout/)

## A worked example with two outcomes

This example is illustrative. The `checkout` service runs 4 tasks with a HikariCP pool of 10 each against the orders database, `max_connections` 100. At 09:14 UTC checkout logs `Connection is not available, request timed out after 30002ms (total=10, active=10, idle=0, waiting=41)` on every task.

First outcome, the database is slow:

| Check | Result |
| --- | --- |
| Sessions from `checkout` by state | 40 `active`, wait event `Lock` / `transactionid` |
| `blocked_by` on the oldest | pid 48211, application `orders-backfill`, `idle in transaction` for 11 minutes |
| `hikaricp.connections.usage` | p99 30 s, matching query time |

A backfill job opened a transaction, updated rows checkout reads with `SELECT ... FOR UPDATE`, and stopped. Every checkout connection waits behind it. The pool is a victim; the fix is the backfill session.

Second outcome, checkout holds the connections:

| Check | Result |
| --- | --- |
| Sessions from `checkout` by state | 38 `idle in transaction`, wait event `ClientRead`, 2 `active` |
| Active query times | under 20 ms |
| `hikaricp.connections.usage` | p99 29 s, far above query time |

The release at 09:05 added a call to the payments API inside the order transaction. Payments slowed, so each request held its transaction (and its connection) while waiting for payments. The database is idle. The dependency to investigate is payments, and the code change is the open transaction around a remote call.

## Limits

`pg_stat_activity` is a snapshot; take it during the timeouts, not after. A pooler such as PgBouncer between the service and PostgreSQL changes what the database sees: `client_addr` becomes the pooler, and in transaction pooling a session's `idle` state says little about one application connection. Pool metrics show what one process saw. Add them up across tasks before comparing with the database. [Monitoring statistics](https://www.postgresql.org/docs/current/monitoring-stats.html)

When new connections are refused because the database is at its limit, the next question is who holds the slots, and whether a rollout's overlap added them. [Who holds the connections](/learn/postgres-who-holds-connections/) · [Connection budgets during rollouts](/learn/connection-limits/) · [All runtime dependency failures](/learn/runtime-dependency-failures/)

## Questions

### Does raising the pool size fix a pool timeout?

Only in the last row of the table, and only if the database has slots to spare. When slow queries or a blocking session hold the connections, a bigger pool adds more waiting sessions. When the database is at `max_connections`, a bigger pool cannot open its extra connections at all.

### Why does the pool say active when the database says idle?

The pool counts a borrowed connection as active until the application returns it. The database reports what the session is doing, and a session that ran its query and is waiting for the next command shows `idle` or `idle in transaction`. The gap is time the application spent holding the connection without using it.

### What does waiting mean in the HikariCP message?

It is the number of threads blocked in `getConnection()` at that moment, waiting for a connection to come back. A large value with `active` at the maximum means requests queue in the application before they ever reach the database.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Who is holding all the PostgreSQL connections right now?](/learn/postgres-who-holds-connections/)
    
    Capacity overruns The Proofline team November 23, 2026 6 min read
    
-   ### [How rolling deployments change your PostgreSQL connection budget](/learn/connection-limits/)
    
    Capacity overruns The Proofline team November 5, 2026 9 min read
