Redis can't connect remotely

Open the redis.conf (redis_6379.conf for windows) file, comment bind 127.0.0.1, and modify the value of protected-mode to no

Then start the redis server. Use the local client command redis-cli to connect to the redis server,

After the connection is successful, execute the following command to set the password of redis (here it is set to 123):



 

Then test with client commands on other machines:

redis-cli -h 192.168.1.225 -p 6379 -a 123

After the connection is successful,

execute keys *

If no error is reported, the configuration is successful. If you configure a redis connection in spring data, you also need to set a password:

The settings are as follows:

 

<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
          destroy-method="destroy">
        <property name="poolConfig" ref="jedisPoolConfig"/>
        <property name="hostName" value="${redis.host}"></property>
        <property name="port" value="${redis.port}"></property>
        <property name="timeout" value="${redis.timeout}"></property>
        <property name="usePool" value="${redis.usePool}"/>
        <property name="password" value="123" />
    </bean>

 123 here is the connection password.

Guess you like

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