redis/jedis · error · JedisConnectionException
All configured databases are unhealthy. Cannot initialize…
Error message
All configured databases are unhealthy. Cannot initialize MultiDbConnectionProvider.
What it means
After iterating every configured database in weight order and waiting for each health check, if the InitializationPolicy never returned SUCCESS (typically because no database ever reported healthy), MultiDbConnectionProvider throws JedisConnectionException stating all configured databases are unhealthy. The client cannot select an active database, so initialization fails.
Solutions
- Test each configured endpoint from the application host with redis-cli -h <host> -p <port> PING and fix connectivity.
- Verify credentials (username/password) and TLS settings in each database entry of MultiDbConfig.
- Wait for the Redis fleet to recover or fix the environment (DNS, firewall, VPN) before restarting the client.
- Review health check configuration (endpoints used for probing, timeouts) to rule out systemic false negatives.
Example fix
// before
.database(MultiDbConfig.databaseConfigBuilder()
.connectionConfig(RedisURI.builder().host("redis-primary.internal").port(6379).build())
.weight(1.0f).build()) // host unreachable from app env
// after — verify host reachable, or use correct internal DNS
.database(MultiDbConfig.databaseConfigBuilder()
.connectionConfig(RedisURI.builder().host("redis-primary.prod.svc.cluster.local").port(6379).build())
.weight(1.0f).build()) Defensive patterns
Strategy: retry
Validate before calling
// Check all endpoints before constructing the provider
boolean anyHealthy = config.getDatabases().stream().anyMatch(db -> {
try (Jedis p = new Jedis(db.getHost(), db.getPort())) {
return "PONG".equals(p.ping());
} catch (Exception e) { return false; }
});
if (!anyHealthy) throw new IllegalStateException("No Redis endpoint reachable"); Try / catch
int attempts = 0;
while (attempts++ < 5) {
try { client = MultiDbClient.builder().multiDbConfig(cfg).build(); break; }
catch (JedisConnectionException e) {
Thread.sleep(2000L * attempts); // retry: fleet may be recovering
}
} Prevention
- Deploy against a fleet with redundancy so 'all unhealthy' requires a total outage.
- Alert on Redis health so the fleet is restored before clients restart.
- Validate DNS/firewall/VPN paths from the app environment in CI smoke tests.
- Double-check that all endpoint URIs point to the right environment (staging vs prod).
When it happens
Trigger: Building a MultiDbClient where every endpoint in databaseMap ends up with an unhealthy HealthStatus after waitForHealthStatus completes for all of them, and the initialization policy evaluates to CONTINUE for each endpoint until the loop exhausts the list.
Common situations: Entire Redis fleet down or unreachable (network outage, VPN not connected); all endpoints misconfigured (bad hosts/ports or wrong credentials causing health check failures); security group/firewall blocking health check ports; Redis persisting in a state that fails the health probe.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Initialization failed due to initialization policy
- Initialization failed due to initialization policy
- No healthy database available after initialization policy…
- failed to connect. Please check configuration and try again.
- Attempting to write to a broken connection.
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/e5b0fdae8af45122.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java:463
log.debug("No health check configured for database {}, defaulting to HEALTHY", endpoint);
}
ConnectionInitializationContext evalCtx = new ConnectionInitializationContext(databaseMap,
healthStatusManager);
Decision d = evalCtx.conformsTo(policy);
log.debug("Policy evaluation after {}: {}", endpoint, d);
if (d == Decision.SUCCESS) {
return selectBestAvailableDatabase(sortedDatabases);
}
if (d == Decision.FAIL) {
throw new JedisConnectionException(
"Initialization failed due to initialization policy: " + evalCtx);
}
// else CONTINUE -> move to the next pending endpoint
}
// All databases are unhealthy
throw new JedisConnectionException(
"All configured databases are unhealthy. Cannot initialize MultiDbConnectionProvider.");
}
/**
* Selects the best available (healthy) database based on weight priority.
* @param sortedDatabases the list of databases sorted by weight in descending order
* @return the highest-weighted healthy database
* @throws JedisConnectionException if no healthy database is available
*/
private Database selectBestAvailableDatabase(
List<Map.Entry<Endpoint, Database>> sortedDatabases) {
log.info("Selecting initial database from {} configured databases", sortedDatabases.size());
// Select first healthy database in weight order
for (Map.Entry<Endpoint, Database> entry : sortedDatabases) {
Endpoint endpoint = entry.getKey();
Database database = entry.getValue();
View on GitHub (pinned to 6dac31d4c2)