UnknownHostException和/ etc / hosts

时间:2013-11-19 16:05:11

标签: java linux host hosts jedis

我在/ etc / hosts文件中有记录,其中包含host-name.com的IPv4和IPv6地址 但我有时会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 stable)with unscd
  • 带有-Djava.net.preferIPv4Stack=true
  • 的java 1.7.0_45
  • /etc/nsswitch.conf有行hosts: files dns
  • / etc / hosts权限-rw-r--r--

0 个答案:

没有答案