使用IDEA连接远程主机上的Redis失败. 抛出redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host xxx

问题: 使用IDEA连接远程主机上的Redis失败. 抛出redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to host xxx
解决方法: 在Redis的配置文件中注释掉bind

测试代码

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class RedisConnectionTest {
    public static void main(String[] args) {
        JedisPool pool = new JedisPool("192.168.31.169", 6379);
        Jedis jedis;

        try  {
            jedis = pool.getResource();
            System.out.println(jedis.ping());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
posted @ 2022-05-27 19:38  GoXXIV  阅读(403)  评论(0编辑  收藏  举报