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

By RunRacks Team · Published

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:

Terminal
sudo systemctl status redis-server   # unit is redis on AlmaLinux/Rocky
redis-cli INFO server | grep redis_version

On 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:

Terminal
redis-cli SET healthcheck ok
redis-cli INFO persistence

A 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:

Terminal
sudo tail -n 50 /var/log/redis/redis-server.log   # /var/log/redis/redis.log on AlmaLinux/Rocky

Typical 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:

Terminal
redis-cli CONFIG GET dir
df -h
sudo du -sh /var/lib/redis/* 2>/dev/null

If 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:

Terminal
sudo journalctl --vacuum-size=200M
sudo apt clean        # Debian/Ubuntu
sudo dnf clean all    # AlmaLinux/Rocky

If Redis writes to a small volume, point it at a larger one by editing dir in /etc/redis/redis.conf, then restart:

INI
dir /var/lib/redis
dbfilename dump.rdb

Fix 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:

Terminal
ps -o user= -p "$(pgrep -f 'redis-server' | head -n1)"
sudo ls -ld /var/lib/redis
sudo ls -l /var/lib/redis/dump.rdb

The 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:

Terminal
sudo chown -R redis:redis /var/lib/redis
sudo chmod 750 /var/lib/redis
sudo chmod 660 /var/lib/redis/dump.rdb

Also 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:

Terminal
sudo sysctl vm.overcommit_memory=1
echo 'vm.overcommit_memory = 1' | sudo tee /etc/sysctl.d/99-redis.conf
sudo sysctl --system

Also 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:

Terminal
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:

Terminal
redis-cli SET healthcheck ok
redis-cli GET healthcheck

To make the change permanent, edit /etc/redis/redis.conf and restart:

Terminal
sudo systemctl restart redis-server
redis-cli INFO persistence | grep rdb_last_bgsave_status

Check it works

Run a full cycle: write a key, force a save, restart Redis and read the key back.

Terminal
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-test

If 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:

Terminal
sudo tail -f /var/log/redis/redis-server.log

Troubleshooting

  • `MISCONF` returns right after you fix the disk → Redis only clears the flag after a successful save. Run redis-cli BGSAVE and check rdb_last_bgsave_status; if it still says err, 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 -i and the output of sudo repquota -s / for the Redis user.
  • `Permission denied` after a restore → the restored dump.rdb is owned by root. Re-run the chown and chmod commands above.
  • `fork: Cannot allocate memory` → overcommit is off or the VPS is out of RAM. Set vm.overcommit_memory=1 and check free -m for 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

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.

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