jedis代码连接redis服务失败

本文详细介绍了如何解决Redis在运行中遇到的连接问题和配置问题,包括如何处理DENIED错误,通过调整protected-mode设置来允许外部连接,以及解决connectiontimeout和connectionrefused错误的方法,如检查并配置防火墙。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1 redis.clients.jedis.exceptions.JedisDataException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions

解决办法:

	方法一
	查看当前redis服务是否开启protected-mode
	>config get protected-mode;
	>yes
	
	方法二
	○ 要不就关闭redis服务,重新确定加载的redis**.conf配置文件;
	○ 要不临时关闭protected-mode
	>config set protected-mode no

2 connection timeout/connection refused

解决办法:
检查当前服务器的centos6.x的防火墙是否开启;
如果开启将其关闭,或者选择对外开放端口
#service iptables status查看防火墙状态
#service iptables stop临时关闭防火墙
#service iptables start 临时开启
#chkconfig iptables off永久关闭
#chkconfig iptables on永久开启

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值