MasterMedia
MasterMedia

Reputation: 355

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?

Upvotes: 4

Views: 13642

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191681

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

Upvotes: 7

Related Questions