How to solve Redis WARNING overcommit_memory is set to 0!

Aug 18, 2022 · 1 min read · Post a comment

As I was working on a docker-compose stack I received the following warning message that was coming from the Redis service:

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot
or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Here are few ways to tackle it down.


  • Redis


Solution #1

The easiest and shortest answer would be to do as the warning says.

Step 1. Open /etc/sysctl.conf file.

sudo vim /etc/sysctl.conf

Step 2. Update or add the following line at the end of the file.

vm.overcommit_memory = 1

Step 3. Save the file and reboot the machine.


It’s worth to mention that this needs to be done on the host machine. Not related to the Docker container at all.

Solution #2

Although, Redis recommends setting the vm.overcommit_memory to 1 by their official FAQ docs, a much better and safer approach would be to do nothing and ignore the warning.

Solution #3

However, if you do experience performance issue, try to scale up the instance in terms of memory.

Solution #4

Last but not least, try playing around with redis-overcommit-on-host GitHub repo.


To find more cool Redis commands and hacks, simply browse the Redis category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.