redis/jedis · error · JedisException
MULTI command failed. Received response:
Error message
MULTI command failed. Received response:
What it means
ReliableTransaction.multi() sends the MULTI command and expects an 'OK' status reply. If the server replies with anything else, it throws JedisException('MULTI command failed. Received response: <status>'). A non-OK MULTI reply indicates the server refused to enter the queued-transaction state (e.g. connection in an unexpected state or an error reply instead of a status).
Solutions
- Inspect the status text in the exception to identify the server's actual reply, then reset the connection (return to pool / reconnect).
- Ensure no commands were issued or left unread on the connection before multi(); use a fresh transaction instance per connection.
- Check for proxies/pool configs that corrupt the protocol stream; retry the transaction on a new connection.
Example fix
// before
Transaction t = jedis.multi();
t.multi(); // may throw on stale connection
// after
try {
t.multi();
} catch (JedisException e) {
connection.close(); // force reconnect
t = jedis.multi();
} Defensive patterns
Strategy: try-catch
Try / catch
try {
transaction.multi();
} catch (JedisException e) {
connection.close(); // reset desynced connection
transaction = createNewTransaction();
} Prevention
- Use one transaction per dedicated connection; never share transactions across threads.
- Drain or close connections that produced protocol errors instead of reusing them.
- Avoid proxies/pools that can interleave replies on transactional connections.
When it happens
Trigger: Calling transaction.multi() when the connection's state desynced from the server — for example reusing a connection that already had errors, a proxy mangling the reply, or a server returning an error string instead of +OK.
Common situations: Connection sharing/pooling bugs where a previous command's error reply is consumed as the MULTI status; failover mid-transaction; sending commands on a broken or stale connection.
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
- Cannot use Jedis when in Multi. Please use Transaction or…
- DISCARD command failed. Received response
- It is not allowed to create Transaction from this
- ${status}
- EXEC without MULTI
AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08).
Data as JSON: /api/errors/8a1dae31e909b826.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/redis/clients/jedis/ReliableTransaction.java:96
* @param closeConnection should the 'connection' be closed when 'close()' is called?
*/
ReliableTransaction(Connection connection, boolean doMulti, boolean closeConnection, CommandObjects commandObjects) {
super(commandObjects);
this.connection = connection;
this.closeConnection = closeConnection;
if (doMulti) multi();
}
private static CommandObjects createCommandObjects(Connection connection) {
return new CommandObjects(RedisProtocol.orServerDefault(connection.getRedisProtocol()));
}
@Override
public final void multi() {
connection.sendCommand(MULTI);
String status = connection.getStatusCodeReply();
if (!"OK".equals(status)) {
throw new JedisException("MULTI command failed. Received response: " + status);
}
inMulti = true;
}
@Override
public String watch(final String... keys) {
String status = connection.executeCommand(commandObjects.watch(keys));
inWatch = true;
return status;
}
@Override
public String watch(final byte[]... keys) {
String status = connection.executeCommand(commandObjects.watch(keys));
inWatch = true;
return status;
}
View on GitHub (pinned to 6dac31d4c2)