In the process of learning Redis, when learning the chapter of using Jedis to operate Redis, I found problems such as failure to connect to Redis and timeout, and made some modifications to Redis configuration files by searching relevant blogs, including: Modify the Redis configuration file, modify the Linux firewall configuration, and directly bind the IP address of Redis

1. Modify the Redis configuration file

See the original post

After the modification, the firewall still cannot be connected. Therefore, the firewall is configured on the VIRTUAL machine

2. Modify the Linux firewall configuration

  • Open port:firewall-cmd --zone=public --add-port=6379/tcp --permanet
  • Reload the firewall:systemctl restart firewalld.service
  • Check firewall status:systemctl status firewalld
  • Check the status of firewall open ports:firewall-cmd --zone=public --list-ports

Still cannot connect after modification…

3. Bind the IP address to connect to the server.

If you still can’t connect to Redis after doing both steps, try this method:

  • First of all byifconfigCopy the IP address of the Linux VM or remote server and save it

  • Then open the Redis configuration file and pass/bind+ Lowercase letter n Quickly locate the location in the following figure

  • Connect to the IP address pasted above in the IDE

The connection succeeded!

== Note: I turned the firewall off during the first test. If it still doesn’t work during the test, try turning the Linux firewall off and connecting again