本地Springboot项目连接服务器Redis总是失败

本地Springboot项目连接服务器Redis总是失败,第1张

一般springboot会报这个错误:Unable to connect to Redis;nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 地址:6379。

最重要的!!!一定要看清你修改的redis.conf是不是启动命令指定的那个

因为刚开始安装的时候,一般会复制一份redis.conf到bin文件夹中,所以一共有两个文件,你要用哪个就要修改对应的配置文件的配置。

./bin/redis-server redis.conf

(这个就是redis文件下的那个redis.conf配置文件,我改了好久bin下的redis.conf没作用,浪费时间!!!)

其他步骤就是:

1.将redis.conf文件中 bind:127.0.0.1 注释掉(不限制连接了) 将application.yml中host改为服务器地址

2.将redis.conf文件中 protected-mode yes 改成 protected-mode no

3.将redis.conf文件中 requirepass 取消注释,加上密码,同时在application.yml中添加spring:redis:password: 密码

4.在阿里云安全组添加端口6379,在linux *** 作页面开启6379端口防火墙

一些关于防火墙的Linux命令

firewall-cmd --list-ports 查看所有开启的端口

systemctl status firewalld 查看防火墙状态

firewall-cmd --zone=public --add-port=6379/tcp --permanent 开启6379端口

systemctl restart firewalld.service 重启防火墙

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/794163.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-06
下一篇2022-05-06

发表评论

登录后才能评论

评论列表(0条)

    保存