百度云服务器 jedis连接超时解决方法,redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeout

redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
	at redis.clients.jedis.Connection.connect(Connection.java:207)
	at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
	at redis.clients.jedis.Connection.sendCommand(Connection.java:126)
	at redis.clients.jedis.BinaryClient.set(BinaryClient.java:110)
	at redis.clients.jedis.Client.set(Client.java:47)
	at redis.clients.jedis.Jedis.set(Jedis.java:120)
	at com.lsy.jedis.JedisDemo1.demo1(JedisDemo1.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

先说问题:使用jedis连接Redis时,下面显示连接超时,爆红;

redis中报错 Redis Creating Server TCP listening socket 32.155.175.175:6379: unable to bind socket, 是redis.conf中闲置了其他ip地址的访问.

解决办法:

步骤一:修改redis.conf的配置文件

 在 redis.conf 中找到 bind 127.0.0.1
直接将 bind 127.0.0.1 改为 bind 0.0.0.0

步骤二:修改完配置文件,进入redis中,终止redis,不终止不会生效;

127.0.0.1:6379> shutdown
not connected> exit

 步骤三:重启redis

[root@ls bin]# ./redis-server ../conf/redis.conf 
3311:C 07 Jun 2022 20:53:50.497 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
3311:C 07 Jun 2022 20:53:50.498 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=3311, just started
3311:C 07 Jun 2022 20:53:50.498 # Configuration loaded

 这种办法可以解决跨ip访问的问题,其它问题可以检查一下防火墙;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值