redis/jedis · warning
Error while validating pooled Connection object.
Error message
Error while validating pooled Connection object.
What it means
This warning is logged by ConnectionFactory.validateObject when a pooled connection fails its periodic health check. The pool calls validateObject before handing a connection to the caller; any exception during re-authentication or PING (socket closed, timeout, protocol error) is swallowed and the connection is reported invalid so the pool destroys it. It is diagnostic, not fatal — the pool simply evicts the bad connection.
Solutions
- Check Redis server logs and network stability between client and server; the underlying exception printed with this warning names the root cause.
- Enable pool test-while-idle / eviction settings so dead connections are culled before validation-time failures.
- If re-authentication failures, confirm username/password in JedisClientConfig match current Redis ACLs.
- Upgrade or tune socket timeout / connect timeout so transient latency does not fail PING.
- If MOVING/retired events are involved, ensure maintenance-event handling is enabled so retired connections are replaced cleanly.
Example fix
// before JedisPool pool = new JedisPool(config, host); // defaults: no idle testing // after GenericObjectPoolConfig<Jedis> pc = new GenericObjectPoolConfig<>(); pc.setTestWhileIdle(true); pc.setTimeBetweenEvictionRunsMillis(30000); pc.setMinEvictableIdleTimeMillis(60000); JedisPool pool = new JedisPool(pc, config, host, port);
Defensive patterns
Strategy: retry
Validate before calling
try (Jedis probe = new Jedis(host, port)) {
probe.ping(); // throws quickly if Redis unreachable before pool use
} Try / catch
try { jedis.ping(); } catch (JedisConnectionException e) { logger.warn("connection dead, will be evicted", e); pool.clear(); } Prevention
- Enable testWhileIdle with a timeBetweenEvictionRunsMillis below any firewall idle timeout
- Keep soTimeout above the slowest command's worst-case latency
- Rotate client credentials in sync with Redis ACL changes
- Monitor Redis restarts/failovers so validation warnings correlate with known events
When it happens
Trigger: PING to Redis times out or throws (server restarted, network drop, connection already closed); reAuthenticate() fails because the password/username changed or ACLs were updated; the connection was marked retired by a MOVING maintenance push after the ping.
Common situations: Redis server restart or failover while a pool holds idle connections; firewall/NAT silently dropping idle TCP connections (validate then fails on first use after idle); credentials rotated in Redis ACL without updating the client config.
Related errors
- Error while validating pooled Jedis object.
- All configured databases are unhealthy. Cannot initialize…
- Database is not healthy
- Maintenance eviction pass failed; retired connections…
- Resource is returned to the pool as broken
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/a3b1e27439b23963.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/ConnectionFactory.java:238
}
@Override
public boolean validateObject(PooledObject<Connection> pooledConnection) {
final Connection jedis = pooledConnection.getObject();
try {
// check HostAndPort ??
if (!jedis.isConnected()) {
return false;
}
if (jedis.isRetired()) {
return false; // marked by a maintenance marking pass -> recycle
}
reAuthenticate(jedis);
// Re-check after the ping: its read may consume a buffered MOVING push whose inline
// marking pass marks this connection.
return jedis.ping() && !jedis.isRetired();
} catch (final Exception e) {
logger.warn("Error while validating pooled Connection object.", e);
return false;
}
}
private void reAuthenticate(Connection jedis) throws Exception {
try {
String result = jedis.reAuthenticate();
if (result != null && !result.equals("OK")) {
String msg = "Re-authentication failed with server response: " + result;
Exception failedAuth = new JedisAuthenticationException(msg);
logger.error(failedAuth.getMessage(), failedAuth);
authXEventListener.onConnectionAuthenticationError(failedAuth);
return;
}
} catch (Exception e) {
logger.error("Error while re-authenticating connection", e);
authXEventListener.onConnectionAuthenticationError(e);
throw e;View on GitHub (pinned to 6dac31d4c2)