5

我在 /etc/hosts 文件中有记录,其中包含 IPv4 和 IPv6 地址host-name.com 但我有时会得到UnknownHostException

redis.clients.jedis.exceptions.JedisConnectionException: java.net.UnknownHostException: host-name.com 
  at redis.clients.jedis.Connection.connect(Connection.java:137) 
  at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:65) 
  at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1706) 
  at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:28) 
  at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188) 
  at redis.clients.util.Pool.getResource(Pool.java:38) 
    ... 2 common frames omitted 
Caused by: java.net.UnknownHostException: host-name.com 
  at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
  at java.net.Socket.connect(Socket.java:579) 
  at redis.clients.jedis.Connection.connect(Connection.java:132) 
    ... 7 common frames omitted

这怎么可能,我该如何解决?

  • 带有 unscd 的 Linux 3.2(Debian 稳定版)
  • java 1.7.0_45 与-Djava.net.preferIPv4Stack=true
  • /etc/nsswitch.conf 有一行hosts: files dns
  • /etc/hosts 权限-rw-r--r--
4

0 回答 0