centos7 redis tcp connection Connection timed out

There are thousands of situations in which the connection fails, and I can't guarantee whether the situations I say below will solve the problems of the developers who read this blog.

Redis is installed on the Alibaba Cloud server, and the system is centos7

Connection tool: redis desktop manager. Program connection uses predis (of course, PHP is the best programming language in the world).

First close the binding:

vim /etc/redis.conf 

Add a pound sign in front of bind xxxx#

Next, set the remote connection password:

requirepass xxxxxx

Protected mode is set to no (this mode is still not set well):

protected-mode

Setup is complete, restart redis

systemctl restart redis.service

If the connection fails, use the command: telnet xxxx 6379. If it fails, it is very likely that the Alibaba Cloud security group has not been set. Enter the management background and set the corresponding security group:


Address access terminal, please use Baidu ip


After the setup is complete, the firewall command should be typed:

##Temporarily open port 6379 and it will fail after restarting the server
firewall-cmd --zone=public --add-port=6379/tcp

Afterwards, if access is not allowed, remember to close:

##View 6379 port status
firewall-cmd --zone=public --query-port=6379/tcp

## Delete port 6379 (no access)
firewall-cmd --zone=public --remove-port=6379/tcp

Setup complete, connection test, done





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324403930&siteId=291194637