1.今天在Java端通过Jedis操作Redis服务器时,出现了java.net.UnknownHostException: 192.168.xxx.xxx错误
如下:
Exception in thread “main” redis.clients.jedis.exceptions.JedisConnectionException: java.net.UnknownHostException: 192.168.xxx.xxx
at redis.clients.jedis.Connection.connect(Connection.java:142)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:75)
at redis.clients.jedis.Connection.sendCommand(Connection.java:83)
at redis.clients.jedis.Connection.sendCommand(Connection.java:79)
at redis.clients.jedis.BinaryClient.auth(BinaryClient.java:533)
at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2131)
at ppp.RedisDemo.main(RedisDemo.java:11)
Caused by: java.net.UnknownHostException: 192.168.xxx.xxx
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at redis.clients.jedis.Connection.connect(Connection.java:137)
… 6 more
检查了好多个点包括如下:
①Redis服务器开了没开
②redis.conf配置文件的bind 127.0.0.1注释掉了没
③防火墙
④在windows上试了试能不能ping通
等等
最后全部都OK!!!
2.然后,无意中发现我的host为什么和别人不太一样
String host = " 192.168.xxx.xxx";
3.人们一般是很难发现这种非技术方面的问题的,那就是我们在直接复制粘贴时会多粘贴一个空格
这就导致了无法识别你的IP地址,然后就会报错
4.删除192前面那个空格后就好了