Search code examples
apache-kafkakafka-topic

Kafka topic cannot be deleted or recreated


I have a Kafka topic that seems to simultaneously exist and not exist.

kafka-topics.sh --bootstrap-server localhost:9092 --topic my-topic --delete 

returns an error:

Topics in [] does not exist

Meanwhile, trying to re-create the topic

kafka-topics.sh --bootstrap-server localhost:9092 --topic my-topic \
 --create --replication-factor 1 --partitions 1

returns

Topic already exists

It does not show up in the topics list with

kafka-topics.sh --list

I suspect some form of corruption but it's no clear how I can fully delete the topic so that it can be re-created


Solution

  • Instead of passing --bootstrap-server try with --zookeeper


    kafka-topics.sh --zookeeper localhost:2181 --topic my-topic --delete