I know it's annoying when your app suddenly throws a Redis error and everything slows down. But this one—MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk—has a quick fix.
The Fast Fix: Free up disk space or grant write permissions
- Check disk space on the drive where Redis stores its data. On Linux, run
df -h /var/lib/redis(or wherever your Redisdiris). If the used space is above 95%, you're probably full. Clear old logs, temp files, or move Redis data to a bigger drive. - Check Redis data directory permissions. Run
ls -ld /var/lib/redis. Ensure the Redis user (usuallyredisornobody) owns it and has write permission. If not, runsudo chown -R redis:redis /var/lib/redis && sudo chmod 755 /var/lib/redis. - If you're in a hurry and losing data is okay, disable persistence temporarily. Connect to Redis CLI and run
CONFIG SET stop-writes-on-bgsave-error no. This tells Redis to keep serving writes even if it fails to save. Warning: You'll lose data if the server restarts. Only do this as a band-aid. - Force a manual save. After fixing space/permissions, run
BGSAVEin Redis CLI. You should seeBackground saving started. Then check withLASTSAVE—it should return a recent timestamp.
After step 4, your Redis server should stop throwing the error and allow writes again.
Why this happens
Redis saves snapshots of your data to disk regularly (by default every 5 minutes if keys changed). When the save fails, Redis by default blocks all writes—kind of a safety feature. It's telling you: "Hey, I can't guarantee your data will survive a crash." The three common reasons:
- Disk full — the partition has less than a few MB free. Redis needs at least a few hundred MB to write a temp file and rename it.
- Permission denied — Redis user can't write to the
dirordbfilenamefile. - Background save process (fork) fails — usually because there's not enough memory to fork the process. You'll see
Can't save in background: fork: Cannot allocate memoryin logs. This is rarer.
Less common variations of the same issue
1. The fork fails due to memory limits
If you see fork: Cannot allocate memory in Redis logs, it means the kernel's overcommit memory setting is off. Redis relies on Copy-on-Write, so it tricks the OS into thinking it needs more RAM than it actually does. Fix: echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf && sysctl vm.overcommit_memory=1. Then restart Redis.
2. The dir is set to a read-only filesystem
Check your Redis config file (/etc/redis/redis.conf). Look for dir ./. If it points to /tmp or a mount that's read-only, change it to /var/lib/redis or another writable path. Restart Redis after.
3. Disk quota exceeded (cloud environments)
If you're on AWS EBS or a cloud server with disk quotas, the filesystem may report No space left on device even if df -h shows free space. Run df -i to check inode usage. If inodes are 100% full, delete unnecessary files (like old Redis logs or temp files) to free inodes.
Prevention: keep this error from coming back
- Set up disk space monitoring. Use a tool like
dfin a cron job or a monitoring agent (Prometheus, Zabbix) that alerts you when disk usage hits 80%. - Configure Redis
maxmemoryandmaxmemory-policy. If you're using Redis as a cache, setmaxmemory 1gbandmaxmemory-policy allkeys-lru. This prevents the dataset from growing forever and filling the disk. - Test your disk I/O. If your disk is slow (like a cheap EBS gp2 volume), Redis may time out during save. Run
fio --randwrite --size=1G --name=test --ioengine=libaio --iodepth=16 --direct=1to check. If writes are slow, upgrade your disk or reduce snapshot frequency. - Change Redis save interval. In
redis.conf, adjustsave 900 1to something likesave 3600 1to snapshot less often. But weigh the risk of data loss.
Pro tip: If you can't afford any data loss, switch to AOF (Append-Only File) persistence. It's slower but writes every write operation to disk. Set
appendonly yesandappendfsync everysecin redis.conf. Then you can turn off RDB snapshots entirely (save "").