Fix Redis MISCONF RDB Snapshot Saving Error
The Redis MISCONF error means a background RDB save failed, so Redis stopped accepting writes. This guide finds the cause and restores saving safely.
- Intermediate
- Linux VPS
- 6 min read
Redis returns MISCONF Redis is configured to save RDB snapshots, but it's currently not able to persist on disk when a background save fails and the server refuses further writes. The fix is almost always disk space, file ownership or memory overcommit — not Redis itself. This guide walks through the diagnosis in order, then re-enables saving without losing data.
The error is a safety switch. Redis sets stop-writes-on-bgsave-error yes by default, so once a BGSAVE fails, every write command returns that message until persistence works again. Reads keep working, which is why some applications appear half-broken.
Before you start
You need:
- A Linux VPS with Redis installed and running, and SSH access as a sudo-capable user such as
deploy. - The Redis CLI available (
redis-cli) and permission to read/var/log/redis/and/var/lib/redis/. - A rough idea of how much data Redis holds, so you can judge whether the disk is simply full.
Check the service is up and note the version, since config file paths differ between distributions:
sudo systemctl status redis-server # unit is redis on AlmaLinux/Rocky
redis-cli INFO server | grep redis_versionOn Debian and Ubuntu the config is usually /etc/redis/redis.conf; on AlmaLinux and Rocky it is /etc/redis/redis.conf too, but the data directory may be /var/lib/redis or /var/lib/redis/6379. Confirm with CONFIG GET dir rather than guessing.
Confirm the error and read the log
First, reproduce the message and see what Redis says about persistence:
redis-cli SET healthcheck ok
redis-cli INFO persistenceA healthy instance shows rdb_last_bgsave_status:ok and a recent rdb_last_save_time. If you see rdb_last_bgsave_status:err, the last save failed. Now read the log for the underlying reason:
sudo tail -n 50 /var/log/redis/redis-server.log # /var/log/redis/redis.log on AlmaLinux/RockyTypical lines are Background saving error, Write error saving DB on disk: No space left on device, or Failed opening the RDB file ... Permission denied. Each points to a different fix below.
Fix disk space problems
A full filesystem is the most common cause. Check the partition that holds the Redis data directory:
redis-cli CONFIG GET dir
df -h
sudo du -sh /var/lib/redis/* 2>/dev/nullIf the data directory sits on a partition at 100%, free space before anything else. Old RDB files, large logs and package caches are usual suspects:
sudo journalctl --vacuum-size=200M
sudo apt clean # Debian/Ubuntu
sudo dnf clean all # AlmaLinux/RockyDo not delete the current dump.rdb or appendonly.aof to free space. That file is your dataset. Move it to another disk instead, or expand the volume, then continue.
If Redis writes to a small volume, point it at a larger one by editing dir in /etc/redis/redis.conf, then restart:
dir /var/lib/redis
dbfilename dump.rdbFix ownership and permissions
If the log says Permission denied or Failed opening the RDB file, Redis cannot write to its data directory. It usually runs as the redis user:
ps -o user= -p "$(pgrep -f 'redis-server' | head -n1)"
sudo ls -ld /var/lib/redis
sudo ls -l /var/lib/redis/dump.rdbThe directory should be owned by redis:redis and writable by that user. A common cause is a manual BGSAVE or a restore done as root, which leaves a root-owned dump.rdb behind:
sudo chown -R redis:redis /var/lib/redis
sudo chmod 750 /var/lib/redis
sudo chmod 660 /var/lib/redis/dump.rdbAlso check that the temp directory Redis uses for the fork is writable — it writes temp-<pid>.rdb in dir first, then renames it.
Fix memory overcommit and fork failures
If the log mentions Can't save in background: fork: Cannot allocate memory, the kernel refused the fork. Redis forks to save, and the child briefly needs address space even though it shares pages copy-on-write. Enable overcommit:
sudo sysctl vm.overcommit_memory=1
echo 'vm.overcommit_memory = 1' | sudo tee /etc/sysctl.d/99-redis.conf
sudo sysctl --systemAlso confirm the instance is not swapping heavily, and that maxmemory is set sensibly for the VPS. If the box is out of RAM, reduce the dataset or move to a larger plan rather than disabling persistence.
Re-enable saving and verify
Once the cause is fixed, trigger a save and confirm it succeeds:
redis-cli BGSAVE
sleep 3
redis-cli INFO persistence | grep -E 'rdb_last_bgsave_status|rdb_last_save_time'You want rdb_last_bgsave_status:ok. Writes should now succeed:
redis-cli SET healthcheck ok
redis-cli GET healthcheckIf you must restore service immediately while you investigate, redis-cli CONFIG SET stop-writes-on-bgsave-error no lets writes through, but your data is not being persisted. Treat it as a temporary measure and set it back to yes once saving works.
To make the change permanent, edit /etc/redis/redis.conf and restart:
sudo systemctl restart redis-server
redis-cli INFO persistence | grep rdb_last_bgsave_statusCheck it works
Run a full cycle: write a key, force a save, restart Redis and read the key back.
redis-cli SET persist-test hello
redis-cli BGSAVE
redis-cli INFO persistence | grep rdb_last_bgsave_status
sudo systemctl restart redis-server
redis-cli GET persist-testIf persist-test returns hello after the restart, snapshots are being written and loaded correctly. Watch the log for a minute to be sure no new errors appear:
sudo tail -f /var/log/redis/redis-server.logTroubleshooting
- `MISCONF` returns right after you fix the disk → Redis only clears the flag after a successful save. Run
redis-cli BGSAVEand checkrdb_last_bgsave_status; if it still sayserr, the original cause is not fixed. - `No space left on device` but `df` shows free space → you may have hit the inode limit or a quota. Check
df -iand the output ofsudo repquota -s /for the Redis user. - `Permission denied` after a restore → the restored
dump.rdbis owned by root. Re-run thechownandchmodcommands above. - `fork: Cannot allocate memory` → overcommit is off or the VPS is out of RAM. Set
vm.overcommit_memory=1and checkfree -mfor swap pressure. - Saves succeed but the error keeps coming back → the dataset may be growing faster than the disk. Monitor usage and consider AOF or a larger volume; see the backup guide below for a safe migration path.
Next steps
- Back up and restore Redis data on a Linux VPS to take a clean copy before you change storage settings.
- Install Redis and secure it with a password if you are rebuilding the instance from scratch.
- Optimize Redis for high-read, low-latency applications to tune persistence and memory for your workload.
- Configure Redis remote access with bind and protected-mode when clients connect from another host.
- Need more RAM or disk for your dataset? Compare Linux VPS plans.
Was this guide helpful?
Still stuck?
Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.
Related guides
Databases
Reset a Forgotten MySQL Root Password on Linux
Recover access to MySQL or MariaDB on a Linux VPS by starting the server with skip-grant-tables, setting a new root password and restarting normally.
- Intermediate
- Linux VPS
- 5 min read
Databases
MySQL Point-in-Time Recovery Using Binary Logs
Recover a MySQL or MariaDB database to an exact moment after a bad write or dropped table by restoring a full backup and replaying binary logs up to the incident.
- Advanced
- Linux VPS
- 7 min read
Databases
How to create a database and user for a web app in MySQL or MariaDB
Set up a utf8mb4 database and a dedicated user with a strong password for WordPress, Laravel or any web app, then test the login before you configure the app.
- Beginner
- Linux VPS
- 4 min read