Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while setting up a multi-broker cluster on Local Machine

Using Kafka on Ubuntu: Zookeeper started Kafka started Topic Created Producer started Consumer started Messages are delivering fine from producer to consumer

I created 2 new server.properties files as: server-1.properties as:

broker.id=1
listeners=PLAINTEXT://:9093
log.dir=C:\kafka\kafka-logs-1

server-2.properties as:

broker.id=2
listeners=PLAINTEXT://:9094
log.dir=C:\kafka\kafka-logs-2

When i started the new broker as:

bin\windows\kafka-server-start.sh config\server-1.properties &

Got Error as:

kafka.common.KafkaException: Socket server failed to bind to 0.0.0.0:9092: Address already in use: bind
like image 281
Rahul Sharma Avatar asked Aug 31 '25 15:08

Rahul Sharma


1 Answers

This happens because the brokers you've added, are both listening to port 9092 which is currently in use by the first broker.

In server-1.properties file you need to add

port=9093

and in server-2.properties

port=9094

Keep these lines listeners=PLAINTEXT://:9093, listeners=PLAINTEXT://:9094 commented out.

Also make sure you use different broker.id for every instance.

If you are trying to setup a Multi-broker Kafka Cluster with a single Zookeeper node, you might find this video useful.

like image 91
Giorgos Myrianthous Avatar answered Sep 03 '25 04:09

Giorgos Myrianthous