redis/jedis · warning
Lost connection to Sentinel
Error message
Lost connection to Sentinel {}. Sleeping {}ms and retrying. What it means
This warning is logged by the Sentinel master/replica subscription task in SentineledConnectionProvider when the pub/sub connection to a Sentinel node is lost. Rather than failing the client, the provider logs the node and a computed backoff delay, sleeps, and retries resubscribing to that Sentinel. It is a recovery-path log, not an exception thrown to the caller; the underlying JedisException is attached to the log record.
Solutions
- No code change needed if clients recover — this is expected resilience logging; verify the retry succeeds in subsequent logs.
- Check connectivity/latency to the Sentinel nodes (host/port list, firewall, DNS).
- Increase Sentinel's client-output-buffer-limit for pubsub if subscribers are being dropped.
- Verify the sleeper/resubscribeDelay settings so retries back off appropriately for your environment.
- Inspect the attached JedisException in the log for the root cause (connection refused vs reset vs timeout).
Example fix
// before: assuming any Sentinel log means an outage
// after: correlate with node identity and check subsequent successful resubscription
LOG.warn("Lost connection to Sentinel {}. Sleeping {}ms and retrying.", node,
subscribeRetryWaitTimeMillis, e); // library-side; users should monitor, not fix Defensive patterns
Strategy: retry
Validate before calling
// check Sentinel reachability before building the client
for (HostAndPort hp : sentinels) {
try (Jedis s = new Jedis(hp)) { s.ping(); } // throws if node unreachable
} Try / catch
// library retries internally; for your own sentinel lookups:
try {
hostPort = client.sentinelResolve(...);
} catch (JedisConnectionException e) {
sleep(exponentialBackoff(attempt)); // then retry
} Prevention
- Monitor Sentinel node health and quorum independently of the app
- Set generous pubsub client-output-buffer limits on Sentinel
- Ensure all listed Sentinel nodes are reachable (firewall/DNS checks)
- Alert on repeated 'Lost connection to Sentinel' warnings rather than ignoring them
When it happens
Trigger: A Sentinel node drops the pub/sub subscription: Sentinel restart, network interruption, Sentinel-side client-output-buffer limit exceeded, Sentinel failover/switchover, or idle connection timeout while the resubscribe thread is running.
Common situations: Flaky network between client and Sentinel quorum; Sentinel instances restarted by ops; long-running services that survive transient Sentinel outages; misconfigured Sentinel output-buffer limits (client-output-buffer-limit pubsub) killing slow subscribers.
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
- Lost connection to Sentinel
- Blocking pub/sub operations are not supported on…
- Unknown message type
- Unexpected message
- Unknown message type
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/725d56910e8da880.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/providers/SentineledConnectionProvider.java:386
initMaster(toHostAndPort(switchMasterMsg[3], switchMasterMsg[4]));
} else {
LOG.debug("Ignoring message on +switch-master for master {}. Our master is {}.",
switchMasterMsg[0], masterName);
}
} else {
LOG.error("Invalid message received on sentinel {} on channel +switch-master: {}.",
node, message);
}
}
}, "+switch-master");
} catch (JedisException e) {
if (running.get()) {
long subscribeRetryWaitTimeMillis = resubscribeDelay.delay(subscribeAttempt).toMillis();
subscribeAttempt++;
LOG.warn("Lost connection to Sentinel {}. Sleeping {}ms and retrying.", node,
subscribeRetryWaitTimeMillis, e);
try {
sleeper.sleep(subscribeRetryWaitTimeMillis);
} catch (InterruptedException se) {
LOG.error("Sleep interrupted.", se);
}
} else {
LOG.debug("Unsubscribing from sentinel {}.", node);
}
} finally {
IOUtils.closeQuietly(sentinelJedis);
}
}
}
// must not throw exception
public void shutdown() {
try {View on GitHub (pinned to 6dac31d4c2)