The bind configuration for Redis Redis

Source: Internet
Author: User
Tags bind redis

In configuration file redis.conf, the default bind interface is, which is the local loopback address. In this case, access to the Redis service can only be connected through a native client, not through a remote connection,

This avoids exposing the Redis service to a dangerous network environment, preventing some unsafe people from casually passing remote
Connect to the Redis service.
If the BIND option is empty, it will accept all connections from the available network interfaces.

The connection is unsuccessful when using Redis;

Import the jar package Jedis-2.7.2.jar in the project, write the test class

	@Test public
	void Testjedissingle () throws Exception {
			//Create a Jedis object
		Jedis Jedis = new Jedis (" ", 6379);
		Jedis.set ("Test", "Hello Jedis");
		String string = Jedis.get ("test");
		System.out.println (string);
		Jedis.close ();

Depending on the value of bind in the redis.conf configuration file, different prompt information is present, but the normal use of Redis in Linux system is not affected;

When bind is not present

  Redis.clients.jedis.exceptions.JedisDataException:DENIED Redis is running in protected mode because protected mod E is enabled, no bind address was specified, no authentication password are requested to clients. The This mode connections is only accepted from the loopback interface. If you want-to-connect from external computers to Redis-adopt one of the following solutions:1) Just disable prot ected 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 are not publicly accessible from Internet if your 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 PROTECTE d 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 does one of the above things in order for the server to start accepting connections from the outside.

When bind the native IP address

The code can be tested, but there are problems with the Linux system

[Root@root redis]#./bin/redis-cli-c
Could not connect to Redis at refused
Could not connect to Redis at refused

When BIND is the default

Code test does not pass Refused:connect

Normal operation in Linux

the current approach, code, and Redis clients in Linux can be used

1. Configure multiple IP addresses in bind, bind

2. Configure the value of bind to bind

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.