An error occurred when Jedis connected to Redis on the virtual machine for the first time

Jedis connection error:

Virtual machine: CentOS 6.3

Redis: 4.0.9

host: fill in the ip address on the virtual machine, ifconfig command

port: the port of Redis, the default is 6379, (write 127.0.0.1 is also correct, I don't know why)


exclude:

1. Is the port not open yet (the firewall is blocked)

Release the firewall of the port and check the occupancy of the port.

The commands for CentOS 6 and 7 firewalls are slightly different. You can Baidu by yourself



2. Redis gateway


    The general idea is: if Redis is directly exposed to the intent, everyone can access the interface. In this way, Redies provides a special network interface, similar to a virtual network card, called loopback, so that the Redis value accepts this. computer with network interface.

    Of course, the default is 127.0.0.1 before, you can change it to the IP address of the virtual machine.


Sure enough, execute the following, successful~~


Guess you like

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