While developing apps using Redis, if you are trying to use the command DEBUG and Redis throws the error “ERR DEBUG command not allowed.”, here’s how you fix it.
The DEBUG POPULATE
command quickly populates your Redis instance with dummy test data that comes in handy during development. Here’s how you use it.
DEBUG POPULATE 10 Test
This command populates the database with 10 keys with key Test:N and value Value:N. If “Test” is omitted, “Key” is used.
While this command runs absolutely fine in Redis 6.x and previous versions; starting with Redis 7.0.0, the DEBUG
command is disabled by default and must be enabled manually in the Redis Config file. Running this command will result in the following error.
ERR DEBUG command not allowed. If the enable-debug-command option is set to "local", you can run it from a local connection, otherwise you need to set this option in the configuration file, and then restart the server.
To enable the DEBUG
command, open the Redis config file from a text editor like nano:
sudo nano /etc/redis/redis.conf
Search for the text enable-debug-command using Ctrl+W
The default value for enable-debug-command
is no which prevents execution of DEBUG commands.
Change it to local if DEBUG
command should be enabled from local machine only (connections from 127.0.0.1)
Change it to yes if DEBUG
command can be executed from remote connections as well.
Save and exit by pressing Ctrl+X and then Y. Now, restart Redis with the command:
sudo service redis-server restart
Now you should be able to use the DEBUG
command. Try it out by running this command again:
DEBUG POPULATE 10 Test
You should now see the Test keys generated.
Share your thoughts and comments below.