Reputation: 111
I'm trying to run a kafka cluster with this command :
kafka-topics.sh --bootstrap-server 127.0.0.1:2181 --topic first_topic --create --partitions 3 --replication-factor 1
and i get this as an error:
[2022-02-03 11:25:28,635] WARN [AdminClient clientId=adminclient-1] Connection to node -1 (/127.0.0.1:2181) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
So i tried to look at kafka_2.12-3.1.0\config\server.properties i have
listeners=PLAINTEXT://localhost:9092
Any help will be very appreciated.
Upvotes: 7
Views: 40330
Reputation: 9
In my case i fixed that error log when I configured the bootstrap-servers into application.yml:
spring:
profiles: dev
kafka:
bootstrap-servers: 127.0.0.1:2181
Maybe the only line you need is bootstrap-servers: 127.0.0.1:2181
Upvotes: 0
Reputation: 1
This is because your zookeeper is not working ,I was facing the same issue but when I run the zookeeper with(I am using wsl)
"zookeeper-server-start.sh ~/kafka_2.13-3.3.1/config/zookeeper.properties" command it starts working
I am running Kafka also if you don't how to run, use this command
"kafka-server-start.sh ~/kafka_2.13-3.3.1/config/server.properties"
hint- modify kafka_2.13-3.3.1 this with the correct version of kafka you are using
Upvotes: 0
Reputation: 32130
2181
is typically the port used by ZooKeeper. If you want to specify that, and you're not running Kafka in KRaft (zookeeper-less mode) then you need to do as @Umeshwaran said and use the --zookeeper
argument.
However, you can use --bootstrap-server
, but if you are doing so then specify the broker address and port, which from your listeners config is 9092
:
kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --topic first_topic --create --partitions 3 --replication-factor 1
This article should clarify things.
Upvotes: 3