开发者社区> 问答> 正文

Java连接redis, 报错Connection refused: connect问题

本机,连接远程redis
iptables关了。
client ping serer OK。
server本地操作ok。
本地操作ok。
====== SET ======
`10000 requests completed in 0.11 seconds
50 parallel clients
3 bytes payload
keep alive: 1
100.00% <= 0 milliseconds
93457.95 requests per second`
====== GET ======
`10000 requests completed in 0.11 seconds
50 parallel clients 3 bytes payload
keep alive: 1
100.00% <= 0 milliseconds
94339.62 requests per second `

`jedis = new Jedis(host, port);

     retStr = jedis.set("test123", "lulu"); `

`redis.clients.jedis.exceptions.JedisConnectionException: java.net
.ConnectException: Connection refused: connect `

请问是什么原因?

展开
收起
落地花开啦 2016-02-06 11:41:33 12637 0
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人

    试试:

    String redisAddress = "127.0.0.1"; 
    int redisPort = 6379; 
    int redisTimeout = 2000; 
    
    JedisPool pool = new JedisPool(new JedisPoolConfig(), RedisAddress, RedisPort, RedisTimeout);
     
    Jedis jedis = pool.getResource(); 
    jedis.set("test123", "lulu"); 
    
    pool.returnResource(jedis);
    2019-07-17 18:38:18
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载