參考來自:
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的辦法?