Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KafkaTool: Can't connet to Kafka cluster

I'm trying to connect to the Kafka using a KafkaTool. I got an error: Error connecting to the cluster. failed create new KafkaAdminClient

Kafka and Zookeeper is hosting in the Docker. I run next commands

   docker network create kafka
   docker run --network=kafka -d --name zookeeper -e ZOOKEEPER_CLIENT_PORT=2181 confluentinc/cp-zookeeper:latest
   docker run --network=kafka -d -p 9092:9092 --name kafka -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092 -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 confluentinc/cp-kafka:latest

Settings for KafkaTool enter image description here

enter image description here

Why does KafkaTool not connect to the Kafka that is hosting in the Docker?

like image 797
MasterMedia Avatar asked Sep 03 '25 05:09

MasterMedia


1 Answers

I'm assuming this GUI is not coming from a Docker container. Therefore, your host machine doesn't know what zookeeper or kafka are, only the Docker network does.

In the GUI, you will want to use localhost for both, then in your Kafka run command, leave all the other variables alone but change -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092

Zookeeper run command is fine, but add -p 2181:2181 to expose the port out to the host so that the GUI can connect

like image 200
OneCricketeer Avatar answered Sep 05 '25 00:09

OneCricketeer