I am trying to create topics in Kafka by following the guide on Apache Kafka website through command line. While running the command:
bin/kafka-topics.sh --c
In my case the error was caused by the fact that I started creating topics before the zookeeper became available. Since I did everything in a script, introducing some latency before creating topics helped. If your zookeeper client port is 2181, you can check the availability of your brokers by:
echo dump | nc zookeeper 2181 | grep brokers