Redis fails to start when the append-only file (AOF) becomes corrupted. Use redis-check-aof to fix the file, but be aware data loss may occur if corruption is in the early part of the file.
The Append-Only File (AOF) is Redis's persistence mechanism that logs all write operations. When Redis detects invalid byte sequences or malformed commands in the AOF file at startup, it refuses to load the corrupted data and aborts with this error. This typically happens after unexpected shutdowns, system crashes, or hardware failures during write operations. The corruption makes the file unreadable, preventing Redis from recovering its state.
If Redis is attempting to restart, stop it completely:
redis-cli shutdown
# or
sudo systemctl stop redis-serverBefore making any repairs, create a backup:
cp /var/lib/redis/appendonly.aof /var/lib/redis/appendonly.aof.backupThis preserves the original file in case you need to analyze it further or try alternative recovery methods.
Diagnose the extent of corruption:
redis-check-aof /var/lib/redis/appendonly.aofThis shows you where the corruption is detected without modifying the file. Note the byte offset reported.
Let redis-check-aof remove the corrupted portion:
redis-check-aof --fix /var/lib/redis/appendonly.aofThe tool will truncate the file at the last valid command, discarding everything after the corruption point. You may lose some recent data depending on when corruption occurred.
Ensure the fixed file is valid:
redis-check-aof /var/lib/redis/appendonly.aof
# Output should show: "AOF appears to be OK"Now start Redis with the repaired AOF:
redis-server
# or
sudo systemctl start redis-serverRedis should now load successfully with data from the last valid point in the AOF.
If corruption is severe or redis-check-aof cannot fix it, consider: (1) Switching to RDB snapshots if you have a recent backup, (2) Using Redis Sentinel or Cluster for failover to a healthy replica, (3) For large AOF files on 32-bit systems, compile and run redis-check-aof on a 64-bit machine to avoid integer overflow issues. Prevent future corruption by: setting appendfsync to "everysec" or "always", ensuring sufficient disk space, enabling AOF rewrite to keep file size manageable, and using proper shutdown procedures. Redis 8.4+ includes aof-load-corrupt-tail-max-size to automatically repair minor tail corruption.
ERR fsync error
How to fix "ERR fsync error" in Redis
CLUSTERDOWN The cluster is down
How to fix 'CLUSTERDOWN The cluster is down' in Redis
ERR Job for redis-server.service failed because a timeout was exceeded
Job for redis-server.service failed because a timeout was exceeded
ERR Unbalanced XREAD list of streams
How to fix "ERR Unbalanced XREAD list" in Redis
ERR syntax error
How to fix "ERR syntax error" in Redis