Redis returns MISCONF and stops accepting writes after BGSAVE failure
Environment
Standalone Redis 6.2 on Linux with AOF disabled and RDB periodic snapshots, persistent storage on network-mounted volume, moderate write traffic from web app.
Symptoms
Errors returned to clients: MISCONF Redis is configured to stop accepting writes, background saving failed; recently a BGSAVE started and terminated with error in server log.
Observations
Server log contains 'Background saving terminated with error', and dmesg shows no OOM killer events. Disk where dump.rdb would be written is near capacity or mounted with permission/IO problems. Redis memory usage below maxmemory but BGSAVE fork failed.
Already attempted
Tried CONFIG SET stop-writes-on-bgsave-error no and then attempted writes; server accepted writes afterwards but this is a temporary and risky setting. Restarting Redis was considered but deferred due to production traffic.
Diagnostic steps
- Inspect Redis logs (redis-server log) around the BGSAVE timestamp for the exact error message and check dmesg and syslog for kernel OOM or I/O errors.
- What the result means: If logs show 'fork: Cannot allocate memory', it's a fork/oom problem. If logs indicate write errors or 'No space left on device', it's a storage capacity or permission issue.
- Check free disk space and filesystem health on the directory where dump.rdb is written (df -h and dmesg for I/O errors); if using NFS, check mount options and server-side availability.
- What the result means: Low free space or I/O errors explain failed RDB write. If NFS shows stale mounts or permissions problems, persistence will fail until storage is fixed.
- Run Redis CONFIG GET stop-writes-on-bgsave-error and inspect vm.overcommit_memory and available swap/ram; consider simulating a background save with BGSAVE manual and watch logs.
- What the result means: If stop-writes-on-bgsave-error is enabled and BGSAVE still fails, avoid disabling it until root cause fixed. If overcommit is strict and fork fails, adjust OS settings or ensure enough memory/swap for copy-on-write.
- If you must allow writes temporarily, perform CONFIG SET stop-writes-on-bgsave-error no, then trigger a manual BGSAVE and monitor; plan to revert the config after resolving the storage/fork issue.
- What the result means: If writes are accepted but BGSAVE still fails, data will not be persisted; risk of data loss on crash. If manual BGSAVE succeeds, persistence restored and safe to leave writes enabled, but underlying cause should still be investigated.
Confirmed fixes
No fix has been independently verified for this scenario. Treat the causes below as diagnostic hypotheses.
Question
How to safely diagnose root cause of BGSAVE failure and restore write capability without data loss, and what precautions before toggling stop-writes-on-bgsave-error?
Verified community troubleshooting
First, read the Redis server log entry for the BGSAVE failure and correlate with df -h and dmesg around the timestamp. A 'No space left on device' or write errors point to storage; 'fork: Cannot allocate memory' indicates fork/overcommit issues. Fix the underlying cause (free space, fix NFS mount, adjust overcommit or add swap), then trigger a manual BGSAVE. Only after a successful BGSAVE is it safe to rely on writes; temporary CONFIG SET stop-writes-on-bgsave-error no is reversible but accept the risk and revert after persistence is restored.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Databases38% match
Redis reports MISCONF 'stop writes on BGSAVE error' after BGSAVE failure — how to debug and recover safely?
Open0 answers - Databases22% match
Redis replica stops applying updates after RDB mismatch during background save (BGSAVE)
Open0 answers - Databases21% match
Redis replica stops applying updates after RDB mismatch during BGSAVE causing replication gap and growing replication backlog
Open1 answer