MISCONF Redis is configured to save RDB snapshots [Solved]

avatar
Borislav Hadzhiev

Last updated: Apr 5, 2024
4 min

banner

# Table of Contents

  1. MISCONF Redis is configured to save RDB snapshots
  2. Restart your Redis Server on Windows
  3. Restart your Redis Server on macOS
  4. Restart your Redis Server on Linux
  5. Disable the stop-writes-on-bgsave-error setting
  6. Dealing with memory issues on Linux
  7. Running into permission issues on Linux
  8. Check your Redis server logs

# MISCONF Redis is configured to save RDB snapshots [Solved]

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.

# Restart your Redis Server on Windows

If you are on Windows:

  1. Press Windows + R.
  2. Type services.msc and press Enter.

type services msc

Alternatively, you can click on the search field, type Services and start the application.

search services

  1. Search for the Redis service.
  2. Right-click on it and select Restart.

# Restart your Redis Server on macOS

If you are on macOS:

  1. Open your terminal (e.g. bash or zsh).

  2. Issue the brew services restart redis command.

shell
brew services restart redis

You can also manually stop and start the Redis service.

shell
# 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.

  1. Stop your Redis server by issuing the following command.
shell
brew services stop redis
  1. Start your Redis server.
shell
brew services start redis
  1. Run the following command.
shell
redis-server

You might get prompted whether you want to allow the incoming request. Confirm to resolve the issue.

# Restart your Redis Server on Linux

If you are on Linux:

  1. Open your terminal (e.g. bash or zsh).
  2. Run one of the following commands.
shell
sudo service redis restart sudo systemctl restart redis sudo service redis-server restart sudo systemctl restart redis-server.service

restart redis server on linux

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.

# Disable the stop-writes-on-bgsave-error setting

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

shell
redis-cli config set stop-writes-on-bgsave-error no

disable stop writes on bgsave error setting

The error should be resolved after disabling the setting.

# Dealing with memory issues on Linux

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.

shell
# 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.

shell
sudo su echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf sysctl vm.overcommit_memory=1

increase redis memory allocation

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.

shell
# on Linux sudo sysctl -p /etc/sysctl.conf # on FreeBSD sudo /etc/rc.d/sysctl reload

restart sysctl

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.

shell
# 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.

/etc/sysctl.conf
vm.overcommit_memory = 1

Save the file and exit.

Run the following commands to restart sysctl.

shell
sysctl vm.overcommit_memory=1 # on Linux sudo sysctl -p /etc/sysctl.conf # on FreeBSD sudo /etc/rc.d/sysctl reload

# Running into permission issues on Linux

If you are on Linux and the error persists, you might be running into permission issues.

  1. Run the following commands from your terminal.
shell
redis-cli CONFIG GET dir CONFIG GET dbfilename

get redis config directory and file

  1. Make note of the path to your configuration directory and file.

  2. 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.

shell
# check permissions of directory sudo ls -ld /var/lib/redis # check permissions of file sudo ls -l /var/lib/redis

check redis config directory and file permissions

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.

Make sure to specify the path to the directory and file you got from the output of the commands.
shell
sudo chmod -R 755 /var/lib/redis sudo chmod 644 /var/lib/redis/dump.rdb

update permissions of redis configuration directory and file

# Check your Redis server logs

Try to check your Redis server logs if the error persists.

shell
# 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.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.