I am running this kafka producer example mentioned in its site
The code:
public class TestProducer { public static void main(String[] args) {
This can happen if the client cannot reach BOTH hostname and IP of the kafka broker.
Make an entry to the clients \etc\hosts or C:\Windows\System32\drivers\etc\hosts and that resolved this issue for me.