Scenario:
- Kafka client 2.4.0
- Java 1.8.0_151
- Kafka cluster is running on a machine with hostname ‘ubuntu-confluent’
- Producer has bootstrap.servers=10.0.0.x (ip of same host as ubuntu-confluent)
- At runtime, it appears hosthame is passed back to client
- Subsequent network calls from client back to cluster appear to use hostname instead of ip, and it fails
Exception on client:
2020-03-08 21:26:06,144 [kafka-producer-network-thread | producer-1] WARN org.apache.kafka.clients.NetworkClient [] - [Producer clientId=producer-1] Error connecting to node ubuntu-confluent:9092 (id: 0 rack: null) java.net.UnknownHostException: ubuntu-confluent: nodename nor servname provided, or not known at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[?:1.8.0_151] at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[?:1.8.0_151] at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[?:1.8.0_151] at java.net.InetAddress.getAllByName0(InetAddress.java:1276) ~[?:1.8.0_151] at java.net.InetAddress.getAllByName(InetAddress.java:1192) ~[?:1.8.0_151] at java.net.InetAddress.getAllByName(InetAddress.java:1126) ~[?:1.8.0_151] at org.apache.kafka.clients.ClientUtils.resolve(ClientUtils.java:104) ~[kafka-clients-2.4.0.jar:?]
Easiest fix is to just add an entry to /etc/hosts.