anuja Mandlecha
anuja Mandlecha

Reputation: 115

kafka consumer is unable to connect to its zookeeper

I have kafka and zookeeper running in a standalone mode on an ec2 instance. I have a topic named dev_spark1 created on it. But when I am trying to run consumer from command line, gives me following error for command:

./bin/kafka-console-consumer.sh --zookeeper 172.31.8.226:9092 --topic dev_spark1

  Exception in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
        at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:880)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
        at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
        at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:171)
        at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:126)
        at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:143)
        at kafka.consumer.Consumer$.create(ConsumerConnector.scala:94)
        at kafka.tools.ConsoleConsumer$.main(ConsoleConsumer.scala:145)
        at kafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala)

Upvotes: 2

Views: 2667

Answers (1)

Sunil Patil
Sunil Patil

Reputation: 659

Are you sure that the zookeeper server is accessible from the machine where you have kafka ?

Normally zookeeper listens on port 2181 and kafka listens on port 9092. In your command your trying to connect to zookeeper on 172.31.8.226 on port 9092, is that correct.

Other way to figure this out is there is, run this command on your zookeeper machine first then on the kafka machine and check if you can connect and try out zookeeper.

bin/zookeeper-shell.sh --zookeeper 172.31.8.226:9092

If you have ability to run UI, you can use ZooInspector

Upvotes: 1

Related Questions