Solve this problem is not easy ah, say all is tears, baby Heart bitter!!!
Here are the steps to resolve:
1. Comment out bind 127.0.0.1
Because the configuration file binds to the local IP, this configuration causes the other IP access to be denied, so we comment it out
2. Change protected-mode Yes to Protected-mode no
Because Redis runs in protected mode by default (in this mode, Access does not require a password), this mode only allows local loop access
3. After you have done 2, you need to set the Redis code:requirepass xxx(password)
4. Turn off the firewall:service iptables Stop(this method only temporarily shuts down the fire wall, the next boot system will be invalidated, the Redis port can be added to the firewall rules, in particular, to query the firewall related knowledge)
5. Restart the Redis service, but you will need to specify a specific file:./redis-server. /redis.conf
After all 5 points have been completed, running the code in the console should be successful:
New Jedis ("193.168.1.106", 6379); Jedis.auth ("xxx"); System.out.println ("Connection succeeded"// Check whether the service is running System.out.println ("service is running:" +jedis.ping ());
Operation Result:
Connection Successful
Service is running: PONG
Finish!
Hope to meet this problem of friends have help, thank you!
The Redis host cannot access the problem under
Linux (Centos6.9)