What the message looks like
(error) MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.
# Failed opening the temp RDB file temp-1234.rdb (in server root dir /var/lib/redis) for saving: Permission deniedCommon causes
- The disk or partition holding the Redis data directory is full, or out of inodes. Saving needs room for a complete new RDB file next to the old one.
- The directory is not writable for the user Redis runs as, or the filesystem is mounted read-only. Systemd hardening such as
ProtectSystemcan also make a custom directory read-only for the service. - The background save forks the process and the fork fails with
Cannot allocate memory, typical on small servers withvm.overcommit_memory = 0and a large dataset. - Storage problems underneath: an unavailable network mount, a missing Docker volume, or a disk with I/O errors.
- The configured
dirordbfilenamedoes not exist or points to a wrong path after a config change.
Check
- Status of the last background save
redis-cli INFO persistence | grep -E 'rdb_last_bgsave_status|rdb_last_save_time|rdb_changes_since_last_save' - Cause in the Redis log
- Data directory: owner, free space and inodes
d=$(redis-cli CONFIG GET dir | tail -n 1); ls -ld "$d"; df -h "$d"; df -i "$d" - Memory overcommit setting (1 is recommended for Redis)
sysctl vm.overcommit_memory
Fix
- Find the real cause first. The Redis log and
INFO persistence(rdb_last_bgsave_status:err) name it, usually in a line likeFailed opening the temp RDB fileorCan't save in background: fork. - Disk full: free space or inodes (old logs, old dumps) or enlarge the volume. Leave room for roughly one extra copy of the dataset.
- Permissions: make the data directory writable for the Redis user, for example
chown redis:redis /var/lib/redis, and check the systemd unit if you use a custom directory. - Fork fails: set
sysctl -w vm.overcommit_memory=1and make it permanent in/etc/sysctl.d/99-redis.confwithvm.overcommit_memory = 1. This is what the Redis documentation recommends. Also keep memory free for the child process. - Check the result with
redis-cli BGSAVEandINFO persistence. Oncerdb_last_bgsave_statusisok, writes work again by themselves. - Only as a last resort for a pure cache,
redis-cli CONFIG SET stop-writes-on-bgsave-error nolets writes through while saving fails. It hides the problem and risks data loss if persistence matters, so turn it back on after the repair.
Typical scenario
A small VPS with 2 GB of RAM runs Redis as a session store with an application on the same server. In the night the application suddenly reports MISCONF on every login. The Redis log says Can't save in background: fork: Cannot allocate memory, and sysctl vm.overcommit_memory shows 0. After vm.overcommit_memory = 1 and a successful BGSAVE writes work again without a restart.
FAQ
Do I lose data when MISCONF appears?
Data already in memory stays, and reads still work. What is at risk is everything written since the last successful save if Redis restarts now. That is why Redis stops accepting writes instead of continuing silently.
Is it safe to just restart Redis?
Not as a first step. If the save keeps failing, a restart loads the old RDB file and discards everything newer. Fix the cause and get a successful BGSAVE before any restart.
The error appears although the disk is not full. What is it then?
Then permissions or memory are the likely reasons. The Redis log tells: Permission denied points to permissions, Cannot allocate memory to the fork. Check inodes with df -i as well.
What does MISCONF mean with AOF?
With appendonly active there is a separate message pointing to errors writing the AOF file. The causes are similar (space, permissions), and the check goes through the Redis log.
How do I avoid it in the future?
With monitoring of free space in the data directory and of rdb_last_bgsave_status. The value can be queried regularly from INFO persistence, so an alert comes before Redis blocks writes.