redis/jedis · warning
Error while force disconnecting connection:
Error message
Error while force disconnecting connection:
What it means
This is a warning logged by TrackingConnectionPool.forceDisconnect() when calling connection.forceDisconnect() on one of its tracked connections throws an exception. The pool catches the exception per-connection so that one bad socket does not prevent the remaining connections from being force-disconnected; it logs the connection identity and the underlying cause, then continues the loop. It typically surfaces during client close/failover shutdown when the underlying socket is already dead.
Solutions
- Inspect the logged cause ('e') — if it is a socket closed/broken pipe error, the connection was already dead and the warning is benign; no action needed.
- Avoid closing the client (or calling forceDisconnect) concurrently from multiple threads; ensure a single shutdown path.
- Upgrade Jedis — connection teardown error handling has been hardened across releases.
- If it happens repeatedly during failover, verify the endpoint health and network stability before the shutdown/failover is triggered.
Example fix
// before
pool.forceDisconnect(); // warnings if sockets already dead, unclear cause
// after
try {
pool.forceDisconnect();
} catch (Exception e) {
log.warn("forceDisconnect failed during shutdown", e); // check logged per-connection cause
} Defensive patterns
Strategy: try-catch
Try / catch
try {
client.close(); // internally force-disconnects tracked connections
} catch (Exception e) {
log.warn("Client shutdown reported force-disconnect issues; per-connection causes were logged by the pool", e);
} // per-connection 'Error while force disconnecting' warnings for already-dead sockets are benign and need no retry Prevention
- Close the client from a single thread/shutdown hook; never call close() and failover handlers concurrently.
- Expect these warnings after killing Redis or dropping the network — treat them as informational when the cause is a closed socket.
- Check the logged underlying cause before reacting; only investigate if the exception is unexpected (not socket-closed/broken-pipe).
When it happens
Trigger: Calling forceDisconnect() (e.g. during client close or a failover-driven shutdown) on a connection whose underlying socket close/disconnect throws — e.g. socket already closed, broken pipe on the socket channel, or an IOException raised by the connection implementation during forced teardown.
Common situations: Shutting down a RedisClient/UnifiedJedis after the Redis server was killed or the network dropped; concurrent close from multiple threads where one thread already closed the connection; failover handlers in the mcf (multi-db) module tearing down connections to a dead endpoint.
Related errors
- Database is not healthy
- Failed to create connection!
- Failed to evict connections from pool
- <server status code reply>
- Cluster retry deadline exceeded.
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/953ea410fc24a65f.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/mcf/TrackingConnectionPool.java:77
@Override
protected void initialize(Connection conn) {
// Track the connection while it is being initialized so forceDisconnect() can interrupt
// a thread that is blocked inside HELLO/AUTH/CLIENT round-trips.
factoryTrackedObjects.add(conn);
try {
super.initialize(conn);
} finally {
factoryTrackedObjects.remove(conn);
}
}
public void forceDisconnect() {
for (Connection connection : factoryTrackedObjects) {
try {
connection.forceDisconnect();
} catch (Exception e) {
log.warn("Error while force disconnecting connection: " + connection.toIdentityString(),
e);
}
}
}
}
public static class Builder {
private HostAndPort hostAndPort;
private JedisClientConfig clientConfig;
private GenericObjectPoolConfig<Connection> poolConfig;
private Cache cache;
private MaintenanceNotificationsConfig maintenanceNotificationsConfig;
public Builder hostAndPort(HostAndPort hostAndPort) {
this.hostAndPort = hostAndPort;
return this;
}View on GitHub (pinned to 6dac31d4c2)