redis/jedis · error · JedisConnectionException
JedisConnectionException
Error message
JedisConnectionException
What it means
TrackingConnectionPool.makeObject wraps any non-JedisConnectionException thrown while creating a pooled connection into a new JedisConnectionException whose cause is the original exception. Genuine connection failures (JedisConnectionException) are rethrown unchanged; everything else — DNS resolution errors, factory configuration problems, IO classes, runtime errors — surfaces as this wrapping exception.
Solutions
- Inspect the exception's cause chain (getCause()) to find the root error — the wrapper itself carries no detail.
- Fix the underlying cause: correct DNS/host, TLS settings, or ConnectionFactory configuration.
- If a custom factory is in use, ensure it either returns a connection or throws JedisConnectionException directly.
- Test endpoint reachability (redis-cli PING / nslookup) to separate DNS/network issues from client bugs.
Example fix
// before
} catch (Exception e) {
throw new JedisConnectionException(e); // opaque without cause handling
}
// after
try {
Connection c = pool.getResource();
} catch (JedisConnectionException e) {
Throwable root = e;
while (root.getCause() != null) root = root.getCause();
log.error("connection setup failed: {}", root.getMessage(), root); // diagnose real cause
} Defensive patterns
Strategy: try-catch
Validate before calling
try { InetAddress.getByName(host); } catch (UnknownHostException e) { /* fix hostname before init */ } Try / catch
try {
conn = pool.getResource();
} catch (JedisConnectionException e) {
Throwable root = e;
while (root.getCause() != null) root = root.getCause();
log.error("connection setup failed: {}", root.getMessage(), root);
} Prevention
- Always log the full cause chain, not just the wrapper message.
- Validate hostnames and TLS configuration before building the pool.
- Keep custom ConnectionFactory implementations throwing JedisConnectionException.
When it happens
Trigger: Connection factory throws a non-JedisConnectionException during super.makeObject(): unknown host (UnknownHostException wrapped), socket/SSL initialization errors that are not JedisConnectionException, misconfigured ConnectionFactory, or any RuntimeException from the underlying connection setup.
Common situations: Wrong hostname/DNS entries for a database endpoint; SSL/TLS misconfiguration on the socket factory; classpath or JDK-level errors inside the connection factory; programming errors in custom ConnectionFactory implementations.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to create connection!
- Pool is closed!
- Failed to evict connections from pool
- Endpoint does not exist.
- It is not allowed to create Transaction from this
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/fbedcd79629c2b1a.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/mcf/TrackingConnectionPool.java:56
}
@Override
public PooledObject<Connection> makeObject() throws Exception {
if (failFast) {
throw new JedisConnectionException("Failed to create connection!");
}
try {
PooledObject<Connection> object = super.makeObject();
// this can make a marginal improvement on fast failover duration!
if (failFast) {
object.getObject().close();
throw new JedisConnectionException("Failed to create connection!");
}
return object;
} catch (JedisConnectionException e) {
throw e;
} catch (Exception e) {
throw new JedisConnectionException(e);
}
}
@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 {View on GitHub (pinned to 6dac31d4c2)