Last updated: Apr 5, 2024
Reading time·4 min
The error "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error" occurs when Redis tries to save the database in the background but fails.
To solve the error, restart your Redis server.
If you are on Windows:
Windows
+ R
.services.msc
and press Enter
.Alternatively, you can click on the search field, type Services and start the application.
Redis
service.If you are on macOS:
Open your terminal (e.g. bash
or zsh
).
Issue the brew services restart redis
command.
brew services restart redis
You can also manually stop and start the Redis service.
# Stop the Redis service brew services stop redis # Start the Redis service brew services start redis
If you are on macOS and the issue persists, you might be running into permission issues.
brew services stop redis
brew services start redis
redis-server
You might get prompted whether you want to allow the incoming request. Confirm to resolve the issue.
If you are on Linux:
bash
or zsh
).sudo service redis restart sudo systemctl restart redis sudo service redis-server restart sudo systemctl restart redis-server.service
Your Redis service might be named differently. You can press Tab
to use
autocomplete once you start typing the command, e.g.
sudo systemctl restart red<press Tab>
.
Check if the error is resolved after restarting your Redis server.
stop-writes-on-bgsave-error
settingIf the error persists, open your terminal and disable the
stop-writes-on-bgsave-error
setting.
This would prevent Redis from stopping your write operations when BGSAVE
fails
in the background.
Open your terminal and run the following commands.
redis-cli config set stop-writes-on-bgsave-error no
The error should be resolved after disabling the setting.
The error is also caused due to insufficient memory allocated by your operating system.
The BGSAVE
command fails when it tries to save the DB in the background.
You can usually view the reason why the command failed in your Redis log file.
# on Linux / macOS cat /var/log/redis/redis-server.log # or with tail sudo tail /var/log/redis/redis-server.log -n 100 # path might be different cat /usr/local/etc/redis.conf
The error is often caused when the operating system prevents Redis from allocating sufficient memory, even though the machine has enough RAM.
Linux often thinks that Redis needs much more memory than it actually does and prevents it from forking child processes.
Open your terminal and run the following commands.
sudo su echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf sysctl vm.overcommit_memory=1
Setting overcommit_memory
to 1 prevents Linux from setting unnecessary memory
restrictions that fail the creation of Redis child processes.
Restart sysctl
after running the commands.
# on Linux sudo sysctl -p /etc/sysctl.conf # on FreeBSD sudo /etc/rc.d/sysctl reload
You can also add the line manually to your /etc/sysctl.conf
file.
Run one of the following commands to open the file with your preferred editor.
# open with gedit sudo gedit /etc/sysctl.conf # ------------------------------- # Or open with nano sudo nano /etc/sysctl.conf # ------------------------------- # Or open with vim sudo vim /etc/sysctl.conf
Add the following line at the end of your /etc/sysctl.conf
file.
vm.overcommit_memory = 1
Save the file and exit.
Run the following commands to restart sysctl
.
sysctl vm.overcommit_memory=1 # on Linux sudo sysctl -p /etc/sysctl.conf # on FreeBSD sudo /etc/rc.d/sysctl reload
If you are on Linux and the error persists, you might be running into permission issues.
redis-cli CONFIG GET dir CONFIG GET dbfilename
Make note of the path to your configuration directory and file.
Check the permissions of the directory and file.
Make sure to specify the path to the directory and file you got from the output of the commands.
# check permissions of directory sudo ls -ld /var/lib/redis # check permissions of file sudo ls -l /var/lib/redis
The configuration file is located in the same directory.
The permissions of the directory should be 755
and the permissions of the file
should be 644
.
If you need to change the permissions of your Redis config directory and file, you would issue the following commands.
sudo chmod -R 755 /var/lib/redis sudo chmod 644 /var/lib/redis/dump.rdb
Try to check your Redis server logs if the error persists.
# on Linux / macOS cat /var/log/redis/redis-server.log # or with tail sudo tail /var/log/redis/redis-server.log -n 100 # path might be different cat /usr/local/etc/redis.conf
Your log file might contain information about what causes the issue. j
If you get the error Could not connect to Redis at 127.0.0.1:6379 Connection refused, click on the link and follow the instructions.