Redis is configured to save RDB snapshots, but is currently not able to persist on disk

Redis

Redis Problem Overview


I get the following error, whenever I execute any commands that modify data in redis

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.

I installed redis using brew on mac. How can I get the location of log files where redis-server logs information to. I tried looking for redis conf. file, but couldn't find it either.

What is the default location of [1] redis conf file [2] redis log file.

How do I get rid of the above error, and be able to execute commands that modify data in redis.

Redis Solutions


Solution 1 - Redis

When installing with brew the logfile is set to stdout. You need to edit /usr/local/etc/redis.conf and change logfile to something else. I set mine to:

logfile /var/log/redis-server.log

You'll also make sure the user that runs redis has write permissions to the logfile, or redis will simply fail to launch completely. Then just restart redis:

brew services restart redis

After restarting it'll take a while for the error to show up in the logs, because it happens after redis fails its timed flushes. You should be seeing something like:

[7051] 29 Dec 02:37:47.164 # Background saving error
[7051] 29 Dec 02:37:53.009 * 10 changes in 300 seconds. Saving...
[7051] 29 Dec 02:37:53.010 * Background saving started by pid 7274
[7274] 29 Dec 02:37:53.010 # Failed opening .rdb for saving: Permission denied

After a brew install it attempts to save to /usr/local/var/db/redis/ and since redis is probably running as your current user and not root, it can't write to it. Once redis has permission to write to the directory, your logfile will say:

[7051] 29 Dec 03:08:59.098 * 1 changes in 900 seconds. Saving...
[7051] 29 Dec 03:08:59.098 * Background saving started by pid 8833
[8833] 29 Dec 03:08:59.099 * DB saved on disk
[7051] 29 Dec 03:08:59.200 * Background saving terminated with success

and the stop-writes-on-bgsave-error error will no longer get raised.

Solution 2 - Redis

So I guess it is a bit late for adding an answer here but since I wondered on your question as I had the same error. I got it solved by changing my redis.conf 's dir variable like this:

# The filename where to dump the DB
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 
# The Append Only File will also be created inside this directory.
# 
# Note that you must specify a directory here, not a file name.
dir /root/path/to/dir/with/write/access/

The default value is: ./, so depending on how you launch your redis server you might not be able to save snapshots.

Hope it helps someone !

Solution 3 - Redis

In my case i resolved this issue with below steps

Cause : By default redis store data @ ./ and if redis runs with redis user this means redis will not be able to write data in ./ file then you will face above error.

Resolution : Step # 1 (Enter a valid location where redis can do write operations) root@fpe:/var/lib/redis# vim /etc/redis/redis.conf

dir /var/lib/redis # ( This location must have right for redis user to write)

Step # 2 (Connect to redis cli and map directory to write and issue below variable)

127.0.0.1:6379> CONFIG SET dir "/var/lib/redis"

127.0.0.1:6379> BGSAVE -

This will enable redis to write data on dump file.

Solution 4 - Redis

Was going through the github discussion and the proposed solution is to run >>>config set stop-writes-on-bgsave-error no in the redis-cli. here's the link https://github.com/redis/redis/issues/584#issuecomment-11416418

Solution 5 - Redis

Steps to fix this error:

Go to redis cli by typing redis-cli

127.0.0.1:6379> config set stop-writes-on-bgsave-error no

after that try to set key value

127.0.0.1:6379> set test_key 'Test Value'
127.0.0.1:6379> get test_key
"Test Value"

Solution 6 - Redis

Check the following places:

/usr/local/Cellar/redis...
/usr/local/var/log/redis.log
/usr/local/etc/redis.conf

This error often indicates an issue with write permissions, make sure you're RDB directory is writable.

Solution 7 - Redis

It is usually because permission limits. In my case, it's redis disabled write options.

You can try to run redis-cli in the shell, and then run the following command:

set stop-writes-on-bgsave-error yes

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser462455View Question on Stackoverflow
Solution 1 - RedisKit SundeView Answer on Stackoverflow
Solution 2 - RedismcorbeView Answer on Stackoverflow
Solution 3 - RedisMansur Ul HasanView Answer on Stackoverflow
Solution 4 - RedisShivam Sourav JhaView Answer on Stackoverflow
Solution 5 - RedisGaurav PatilView Answer on Stackoverflow
Solution 6 - RedisFGRibreauView Answer on Stackoverflow
Solution 7 - RedisKane BlueriverView Answer on Stackoverflow