How to fix ERR Transaction was already aborted in Redis
A Redis transaction was aborted due to syntax errors or WATCH key modifications, and you attempted to queue more commands after the abort. Clear the transaction state with DISCARD and verify your commands.
Quick fix
Fixes ERR Transaction was already aborted
DISCARD- Immediately call DISCARD to abort the transaction
- Check what caused the initial abort
- Test each command individually first
- Use redis-cli HELP to verify command syntax
DISCARDERR Transaction was already aborted
What this error means
This error occurs when a Redis transaction (MULTI/EXEC block) has already been aborted and you attempt to queue additional commands without first clearing the error state. Transactions abort when syntax errors are detected during the queuing phase, or when a WATCHed key is modified before EXEC is called. Once aborted, Redis prevents further command queuing until the transaction is explicitly discarded.
Typical symptoms
- Commands queued after an initial error fail with "Transaction was already aborted"
- Unable to execute EXEC after receiving this error
- Subsequent MULTI blocks fail until connection is reset
- Client appears stuck in a transaction state
Common causes
- Syntax error in earlier command within the MULTI block
- Invalid command name or wrong argument count in earlier command
- WATCH key was modified by another client before this error occurred
- Attempting to queue commands after transaction abort without calling DISCARD first
- Memory pressure or other server condition during transaction queuing
How to fix "ERR Transaction was already aborted"
When you see this error, the transaction is in a broken state. Clear it with DISCARD:
DISCARDThis resets the connection to normal state and clears all queued commands.
Review your MULTI/EXEC block for syntax errors:
MULTI
INCRBY mykey 1
SET mystring "value"
EXECCommon issues:
- Wrong number of arguments (e.g., INCRBY missing argument)
- Unknown command name (typo)
- Invalid argument types
- WATCH conflict: another client modified the key
Before retrying, validate each command works in isolation:
INCRBY mykey 1
SET mystring "value"
GET mystringFix any failing commands before putting them in a MULTI block.
Look up the exact syntax for commands:
COMMAND INFO INCRBY
COMMAND INFO SET
COMMAND INFO LPUSHThis shows required vs optional arguments for each command.
WATCH conflicts should be handled gracefully:
let retries = 0;
while (retries < 3) {
try {
const result = await redis.watch('mykey');
if (!result) {
retries++;
continue;
}
const multi = redis.multi();
multi.set('mykey', newValue);
const exec = await multi.exec();
if (exec) break; // Success
retries++;
} catch (e) {
retries++;
}
}With exponential backoff for better results in high-contention scenarios.
Check if server issues caused the abort:
INFO memory
INFO statsIf used_memory is near maxmemory or you see high CPU, the server may be under stress causing transaction failures.
Advanced notes
Redis transaction aborts fall into two categories: (1) Syntax/validation errors caught before EXEC starts - transaction never begins, and (2) WATCH conflicts - transaction is prepared but aborted before execution. The "already aborted" message specifically indicates you tried to queue a command after category 1 error occurred. To avoid this, always validate command syntax before MULTI, or catch syntax errors during MULTI queuing and handle them immediately with DISCARD. Some client libraries (like node-redis) may have dedicated error handling that prevents reaching this state by throwing synchronously on syntax errors. In high-concurrency scenarios, prefer Lua scripts (EVAL) over WATCH for complex multi-step operations, since they execute atomically without requiring explicit transaction queuing.
Frequently asked questions
- What does "ERR Transaction was already aborted" mean?
- This error occurs when a Redis transaction (MULTI/EXEC block) has already been aborted and you attempt to queue additional commands without first clearing the error state. Transactions abort when syntax errors are detected during the queuing phase, or when a WATCHed key is modified before EXEC is called. Once aborted, Redis prevents further command queuing until the transaction is explicitly discarded.
- How do I fix "ERR Transaction was already aborted"?
- A Redis transaction was aborted due to syntax errors or WATCH key modifications, and you attempted to queue more commands after the abort. Clear the transaction state with DISCARD and verify your commands.
- What causes "ERR Transaction was already aborted"?
- Syntax error in earlier command within the MULTI block Invalid command name or wrong argument count in earlier command WATCH key was modified by another client before this error occurred
- Is the "ERR Transaction was already aborted" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Redis Official Documentation
- ๐Redis Transactions Documentation(Official Docs)
- ๐Redis Transactions Guide(Official Docs)