alibaba/druid · critical · GetConnectionTimeoutException
wait millis {waitMillis}, active {activeCount}, maxActive {m
Error message
wait millis {waitMillis}, active {activeCount}, maxActive {maxActive}, creating {creatingCount} What it means
GetConnectionTimeoutException (a SQLException subclass) thrown from getConnection() when no pooled connection could be obtained within maxWait, AND the pool had previously recorded a connection-creation error (createError != null). The creation error is chained as the cause, so this is really a 'pool exhausted because creation is failing' diagnosis: the real reason lives in the cause.
Source
Thrown at core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java:1769
}
List<JdbcSqlStatValue> sqlList = this.getDataSourceStat().getRuningSqlList();
for (int i = 0; i < sqlList.size(); ++i) {
if (i != 0) {
buf.append('\n');
} else {
buf.append(", ");
}
JdbcSqlStatValue sql = sqlList.get(i);
buf.append("runningSqlCount ").append(sql.getRunningCount());
buf.append(" : ");
buf.append(sql.getSql());
}
String errorMessage = buf.toString();
if (createError != null) {
throw new GetConnectionTimeoutException(errorMessage, createError);
} else {
throw new GetConnectionTimeoutException(errorMessage);
}
}
holder.incrementUseCount();
return new DruidPooledConnection(holder);
}
public void handleConnectionException(
DruidPooledConnection pooledConnection,
Throwable t,
String sql
) throws SQLException {
final DruidConnectionHolder holder = pooledConnection.getConnectionHolder();
if (holder == null) {
return;View on GitHub (pinned to fa8dc99126)
Solutions
- Read getNextException / getCause() of the thrown GetConnectionTimeoutException — the createError there is the actual failure (auth refused, connection refused, socket timeout).
- Verify jdbcUrl, username, password, driver class and network reachability to the DB host/port (telnet/nc) from the app host.
- Confirm the JDBC driver jar matches the DB version and is on the classpath; check DriverManager can create a raw connection with the same URL outside the pool.
- Tune maxActive / maxWait upward only after the creation error is fixed; a saturated-but-healthy pool throws error 44, not this one.
Example fix
// before: root cause hidden
catch (GetConnectionTimeoutException e) { log.error(e.getMessage()); }
// after: surface the chained creation error
catch (GetConnectionTimeoutException e) {
Throwable cause = e.getCause();
log.error("pool borrow timed out; underlying create error: {}", cause, cause);
} Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: can we even open a raw connection with these credentials/url?
// run once at startup, not per request
try (Connection raw = DriverManager.getConnection(jdbcUrl, user, pwd)) {
assert raw.isValid(2);
} Try / catch
try {
return dataSource.getConnection();
} catch (GetConnectionTimeoutException e) {
Throwable cause = e.getCause();
if (cause != null) {
// createError is the real reason (auth refused, connection refused)
log.error("borrow timed out due to create failure: {}", cause);
}
throw e;
} Prevention
- Always log getCause() of a GetConnectionTimeoutException — it distinguishes error 43 from 44.
- Validate connectivity at startup with a raw DriverManager probe.
- Keep the driver jar matched to the DB version and on the classpath.
When it happens
Trigger: holder is null after the wait loop (line 1714), createError field is non-null (a prior createPhysicalConnection attempt threw), so line 1769 fires. Produces a message like 'wait millis X, active Y, maxActive Z, creating W, createErrorCount N' plus the chained createError. Happens when the DB is unreachable/unauthenticated and the pool simultaneously empties out.
Common situations: Wrong DB url/credentials/host/port; DB down or refusing connections; firewall dropping the socket so every creation attempt fails while in-flight requests drain the pool; driver class/version mismatch causing creation errors; maxActive saturated while create keeps erroring.
Related errors
- connection closed
- connection disabled
- validationQuery didn't return a row
- maxWaitThreadCount {}, current wait Thread count {}
- onFatalError, activeCount {}, onFatalErrorMaxActive {}
AI-assisted analysis of alibaba/druid@fa8dc99126 (2026-08-14).
Data as JSON: /api/errors/45c2e9d8b3e3cd94.
Report an issue: GitHub.