Send KafkaProducer from local machine to hortonworks sandbox on virtualbox Send KafkaProducer from local machine to hortonworks sandbox on virtualbox hadoop hadoop

Send KafkaProducer from local machine to hortonworks sandbox on virtualbox


You are correct in opening the ports, presumably 9092 and 2181 by default if you're also trying to create/use a Kafka consumer. Kafka however advertises its "hostname" to producers and consumers to use, that name needs to resolve from where you're connecting. The VirtualBox/VM host name does not since there's no entry on the hosting machine that tells it to resolve the hostname and go to localhost in your case and there's nothing that helps resolve it like a DNS. You could edit your hosts file but that's too intrusive. Long story short, Kafka acknowledges this might be a requirement and provides a configuration parameter for you to override what Kafka tells the world about how to get to the broker. Config is called advertised.host.name and advertised.port. Unless you're changing the port you will only need to set the advertised.host.name.

Try setting advertised.host.name in Kafka's server.properties configuration file to localhost. This along with opening the ports should do the trick.