redis/jedis · error · JedisException
${status}
Error message
${status} What it means
Connection.ping() sends the PING command and throws JedisException carrying the raw status reply when the server does not answer exactly 'PONG'. The exception message is the server's actual status response, so the text varies with the reply received.
Solutions
- Check what the exception message says — it is the literal reply the server returned
- Verify the endpoint is actually a Redis server responding to PING with PONG
- Drain pending replies / ensure no unsynced pipeline before calling ping()
- Prefer client.ping() or the pool's built-in health checks instead of raw connection.ping()
Example fix
// before
boolean ok = connection.ping();
// after
try {
boolean ok = connection.ping();
} catch (JedisException e) {
log.warn("PING failed with reply: {}", e.getMessage());
} Defensive patterns
Strategy: try-catch
Validate before calling
// no pre-call check possible; validate endpoint reachability instead Socket s = new Socket(host, port); // ensure a Redis server, not another service, is listening
Try / catch
try {
boolean ok = connection.ping();
} catch (JedisException e) {
log.warn("PING returned unexpected reply: {}", e.getMessage());
} Prevention
- Use high-level client health checks (client.ping()) instead of raw connection.ping()
- Ensure the pipeline is drained before calling ping() so no stale reply is read
- Confirm the host:port points at Redis and not a proxy that rewrites PING
When it happens
Trigger: Calling ping() on a Connection whose server or intermediate layer answers PING with something other than the status reply 'PONG' (e.g. a different message, an error string surfaced as status, or a proxy reply).
Common situations: Health-check code against Redis behind proxies/LBs that rewrite PING responses; connecting to a non-Redis service on the port; custom protocol/handshake states where the previous command's reply is still queued so PING reads a stale reply.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- protocol must not be null
- HostAndPort is required when no socketFactory is provided
- Failed to evict connections from pool
- DIALECT=0 cannot be set.
- Initialization failed due to initialization policy
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/8ec41cc92e27714f.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/Connection.java:1113
protected byte[] encodeToBytes(char[] chars) {
// Source: https://stackoverflow.com/a/9670279/4021802
ByteBuffer passBuf = Protocol.CHARSET.encode(CharBuffer.wrap(chars));
byte[] rawPass = Arrays.copyOfRange(passBuf.array(), passBuf.position(), passBuf.limit());
Arrays.fill(passBuf.array(), (byte) 0); // clear sensitive data
return rawPass;
}
public String select(final int index) {
sendCommand(Command.SELECT, Protocol.toByteArray(index));
return getStatusCodeReply();
}
public boolean ping() {
sendCommand(Command.PING);
String status = getStatusCodeReply();
if (!"PONG".equals(status)) {
throw new JedisException(status);
}
return true;
}
protected boolean isTokenBasedAuthenticationEnabled() {
return authXManager != null;
}
protected AuthXManager getAuthXManager() {
return authXManager;
}
/**
* Returns an unmodifiable view of the registered push consumers.
*
* @return the list of push consumers
*/
List<PushConsumer> getPushConsumers() {View on GitHub (pinned to 6dac31d4c2)