Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the DENIED Redis is running in protected mode problem of redis on Jedis connection Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to solve the DENIED Redis is running in protected mode problem of redis on Jedis connection Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Recently, I haven't written a blog for some time. Today, I took the time to write. When I was developing, the deployment of redis in Linux was caused by others, and I didn't participate much, so I was idle and bored to install a redis on the local virtual machine for testing. I didn't expect to make such a mistake in connecting to the Times. Redis on fuck,Linux is really troublesome, which is as simple as redis on windows.

Exception in thread "main" redis.clients.jedis.exceptions.JedisDataException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 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. 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 3) If you started the server manually just for testing, restart it with the'-- protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside. At redis.clients.jedis.Protocol.processError (Protocol.java:127) at redis.clients.jedis.Protocol.process (Protocol.java:161) at redis.clients.jedis.Protocol.read (Protocol.java:215) at redis.clients.jedis.Connection.readProtocolWithCheckingBroken (Connection.java:340) at redis.clients.jedis.Connection.getStatusCodeReply (Connection.java:239) at redis.clients.jedis.BinaryJedis.ping (BinaryJedis.java:196) at com.example.redis.JedisTest.main (JedisTest.java:24)

After my translation of CET-8, there are four solutions provided above, but all in all, for the sake of simplicity, you only need to perform the following steps:

1. Modify the redis.conf configuration file to annotate the bound ip address and port number as shown in the following figure

two。 Because redis on Linux is in secure mode, which makes it impossible to easily establish a connection from outside the virtual machine, there are two solutions. One is to set the protection mode to no in redis.conf, as shown in the following figure.

4. Well, at this time, you thought it was easy to solve the problem, so after starting the redis server in Linux again, the external connection still reported an error. It was really too young too native. At first, I thought that the configuration did not take effect, because it was clear that the configuration had been written, so I killed the relevant process of redis to restart the service, but found that it was still useless. Finally, the study found that the problem lies in: the redis-server did not specify a configuration file before, but the fucked point of redis on Linux is that if you do not specify a configuration file to start, then your changes are useless and will read the default configuration (PS: I don't know where the default configuration is), so starting in the following way can make the modified configuration file take effect. As for config rewrite ordering me to test, it's no use.

6. Once this problem is solved, all kinds of interesting tests can be carried out. Haha.

This is the end of the content of "how to solve the DENIED Redis is running in protected mode problem of redis on Jedis connection Linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report