Cannot connect to single-node Kafka server through Docker Cannot connect to single-node Kafka server through Docker docker docker

Cannot connect to single-node Kafka server through Docker


You need this:

KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092

Otherwise the Kafka brokers will be telling anyone connecting that it can be found on localhost:9092, which is not going to work from the other containers. From your other containers use kafka:29092 as the broker host & port, as well as zookeeper:2181 for zookeeper.

From your local host machine, you can access your broker on 9092 (assuming you expose the port).

Check out this docker-compose for a full example