问答详情
源自:9-1 springboot整合缓存Redis

连接不到redis Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.43.52:6379

redis装在linux虚拟机上,在xshell上可以成功访问redis,配了密码

拿了老师完整的代码作测试,就是访问失败,不知道哪里出了问题

地址端口密码都没错的,求解

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.43.52:6379

Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.43.52:6379

Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /192.168.43.52:6379

Caused by: java.net.ConnectException: Connection refused: no further information

提问者:迷失代码林 2018-11-04 18:05

个回答

  • weixin_慕少1291444
    2019-01-23 00:23:02

    如需远程连接redis,需配置redis端口6379在linux防火墙中开发

    /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT

    /etc/rc.d/init.d/iptables save

    修改安装目录下的redis.conf文件

    vim redis.conf

    修改以下配置:

    #bind 127.0.0.1 # 将这行代码注释,监听所有的ip地址,外网可以访问
    protected-mode no # 把yes改成no,允许外网访问
    daemonize yes # 把no改成yes,后台运行


  • 慕粉3922874
    2018-12-20 22:57:12

    redis默认是只能本地访问,但是可以通过改配置文件,使能够远程访问。网上应该有详细文档

  • 迷失代码林
    2018-11-04 21:32:28

    redis.conf配置文件中  bind 127.0.0.1生效,因此只能本机访问redis