UnknownHostException和/ etc / hosts

我在/ etc / hosts文件中包含了host-name.com 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 

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

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