2017.7.10 Redis报错:DENIED Redis is running in protected mode
参考来自:
DENIED Redis is running in protected mode
完整错误信息:
1 Caused by: redis.clients.jedis.exceptions.JedisDataException: 2 DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified,
no authentication password is requested to clients. 3 In this mode connections are only accepted from the loopback interface. 4 If you want to connect from external computers to Redis you may adopt one of the following solutions: 5 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 6 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 7 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 8 4) Setup a bind address or an authentication password. 9 10 NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
这里列举了四个解决办法。
我用了第二种。将配置文件里的protected mode改为了no,原本是yes。
2017.7.27 又遇到了这个错误,之前明明将protected-mode改为了no,就ok的。
原因是:之前redis的服务端和客户端都是在本机上,现在客户端在其他机器上,访问redis就出错了。
因此采取了第4种。设置redis的密码。
操作过程:
(1)开启168.2.237.207上的redis
(2)在88环境上连接168.2.237.207上的redis,出错
(3)在168.2.237.207上开一个redis的客户端,连接本机的redis,并且设置密码。
(4)回到88环境,重新连接redis,报错提示:NOAUTH Authentication required。
(5)输入密码,连接成功。
但这里有一个问题:一旦redis服务器重启,又报这个DENIED Redis is running in protected mode的错误了。每次重启后都要重新设置密码才能在别的机器上成功连接。
有没有只设置一次密码就ok的办法?
fighting for this