I have a Kafka cluster running on a Ubuntu machine. I have a kafkajs consumer client, hosted on my Mac (same network as the Ubuntu machine), that successfully connects and consumes messages from Kafka cluster on the Ubuntu machine.
When I publish the kafkajs client to a minishift cluster running on my Mac book, the connections keep on failing with ENOTFOUND. In both cases, the connection is via an IP address e.g. 192.168.10.100:9092. When running in a container, for some reason, the lookup is for the host name of the Ubuntu machine followed by ENOTFOUND.
What could be wrong?
You need to configure how the Kafka brokers advertise themselves. The IP addresses you provide to KafkaJS initially will be used to connect to the brokers, and then query them for other members of the cluster.
See advertised.listeners in https://kafka.apache.org/documentation/#configuration.
Closing this, as it's an issue with operating Kafka, rather than anything to do with KafkaJS. You can take a look at how we run Kafka with docker-compose, although it's a bit more complicated because we're setting up SASL, which you may not need.