i have set the redis config file as " protected-mode no" ,and set the password in the config.but still get the DENIED Redis is running in protected mode because protected mode is enabled……error,how to set it?

i have bind the ip :192.168.1.205

when i use this command

redis-cli -h 192.168.1.205 -p 26379

i get the error

Comment From: antirez

Hello, I cannot replicate, I believe there is some problem in your side since even just binding explicitly any interface will result in protected mode being disabled. Please could you retry making sure you are using the configuration file that you modify? Thanks.

Comment From: bain2018

i have resolve it. we should set config in the sentinel.conf rather than redis.conf

Comment From: srhitesh

+1 Hi, I have tried to Replicate the above mention case with my setup. I have three servers A B C A - Master B&C are slaves

Redis.conf configurations like below for all three Servers

bind 0.0.0.0
protected-mode no
masterauth "mypassword"
requirepass mypassword

After that i have configured three sentinels with below configurations

port 26379
sentinel monitor mymaster 10.18.220.224 8000 2

After running successfully all. I tried to connect A master from B with below command

hitesh@BLR1000010205:~/redis-unstable$ redis-cli -p 26379 -h 10.18.220.224
10.18.220.224:26379> info
DENIED Redis is running in protected mode because protected mode is enabled, ......

Reason ---->

So from above case what i could find ----> Protected mode is enabled (this is the default both in the configuration file and in the config-less default).

So i tried connecting and modifying sentinel.conf with command mode as below but did not work as sentinel is not supporting same.

hitesh@BLR1000009684:~/redis-unstable$ redis-cli -p 26379 
127.0.0.1:26379> CONFIG SET protected-mode no
(error) ERR unknown command 'CONFIG'
127.0.0.1:26379> config set protected-mode no
(error) ERR unknown command 'config'
127.0.0.1:26379> exit

So i added below line in sentinel.conf and tried connecting

protected-mode no

Restarted Sentinel

and tried the same command from B to connect master A sentinel and worked for me.

hitesh@BLR1000010205:~/redis-unstable$ redis-cli -p 26379 -h 10.18.220.224
10.18.220.224:26379> info
# Server
redis_version:999.999.999
redis_git_sha1:0

Comment From: srhitesh

Currently sentinel.c file does not support config cmd.

struct redisCommand sentinelcmds[] = {
    {"ping",pingCommand,1,"",0,NULL,0,0,0,0,0},
    {"sentinel",sentinelCommand,-2,"",0,NULL,0,0,0,0,0},
    {"subscribe",subscribeCommand,-2,"",0,NULL,0,0,0,0,0},
    {"unsubscribe",unsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
    {"psubscribe",psubscribeCommand,-2,"",0,NULL,0,0,0,0,0},
    {"punsubscribe",punsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
    {"publish",sentinelPublishCommand,3,"",0,NULL,0,0,0,0,0},
    {"info",sentinelInfoCommand,-1,"",0,NULL,0,0,0,0,0},
    {"role",sentinelRoleCommand,1,"l",0,NULL,0,0,0,0,0},
    {"client",clientCommand,-2,"rs",0,NULL,0,0,0,0,0},
    {"shutdown",shutdownCommand,-1,"",0,NULL,0,0,0,0,0}
};

If we add the config cmd support in sentinelcmds it is working fine.

struct redisCommand sentinelcmds[] = {
    {"ping",pingCommand,1,"",0,NULL,0,0,0,0,0},
    {"sentinel",sentinelCommand,-2,"",0,NULL,0,0,0,0,0},
    {"subscribe",subscribeCommand,-2,"",0,NULL,0,0,0,0,0},
    {"unsubscribe",unsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
    {"psubscribe",psubscribeCommand,-2,"",0,NULL,0,0,0,0,0},
    {"punsubscribe",punsubscribeCommand,-1,"",0,NULL,0,0,0,0,0},
    {"publish",sentinelPublishCommand,3,"",0,NULL,0,0,0,0,0},
    {"info",sentinelInfoCommand,-1,"",0,NULL,0,0,0,0,0},
    {"role",sentinelRoleCommand,1,"l",0,NULL,0,0,0,0,0},
    {"client",clientCommand,-2,"rs",0,NULL,0,0,0,0,0},
    {"shutdown",shutdownCommand,-1,"",0,NULL,0,0,0,0,0},
    {"config",configCommand,-2,"lat",0,NULL,0,0,0,0,0}
};

@antirez - Please check if you can merge the above change to support config cmd in sentinel.Thx

Comment From: bilalvdemir

@bain2018 your comment: i have resolve it. we should set config in the sentinel.conf rather than redis.conf

it works for me 👍 my config;

supervised systemd dir /var/lib/redis (for db location) protected-mode no

this config in my /etc/redis/redis.conf I copied this file to /etc/redis/sentinel.conf and this works for me 👍

Comment From: vadimsub

i have resolve it. we should set config in the sentinel.conf rather than redis.conf

Thank you! It works for me!

Comment From: iamhritik

thanks but I've just one more query -> can we run sentinel with protected mode set to yes in both the redis and sentinel conf file ?