Cp-docker-images: Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING

Created on 25 Nov 2019  路  7Comments  路  Source: confluentinc/cp-docker-images

winpty docker-compose exec kafka

kafka-topics --create --topic foo --partitions 1 --replication-factor 1 --if-not-exists --zookeeper localhost:32181
Exception in thread "main" kafka.zookeeper.ZooKeeperClientTimeoutException: Timed out waiting for connection while in state: CONNECTING
at kafka.zookeeper.ZooKeeperClient.$anonfun$waitUntilConnected$3(ZooKeeperClient.scala:258)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:253)
at kafka.zookeeper.ZooKeeperClient.waitUntilConnected(ZooKeeperClient.scala:254)
at kafka.zookeeper.ZooKeeperClient.(ZooKeeperClient.scala:112)
at kafka.zk.KafkaZkClient$.apply(KafkaZkClient.scala:1826)
at kafka.admin.TopicCommand$ZookeeperTopicService$.apply(TopicCommand.scala:280)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:53)
at kafka.admin.TopicCommand.main(TopicCommand.scala)

Most helpful comment

Use --zookeeper zookeeper:2181 instead and it will work. That is what is listed in docker-compose.yml:

KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

All 7 comments

+1

+1

Same thing here

Use --zookeeper zookeeper:2181 instead and it will work. That is what is listed in docker-compose.yml:

KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

using port 2181 but not sure why it is throwing the same exception

The solution is to make these modifications to the Kafka server configuration file:

I had this problem on Kafka 2.7 and it worked when using --bootstrap-server localhost:9092 instead of zookeeper (zk connection is deprecated on newest versions of Kafka).

Was this page helpful?
0 / 5 - 0 ratings