How To Fix - Leader Not Available in Kafka Console Producer
This post explains How To Fix - Leader Not Available in Kafka Console Producer
Issue :
- While producing message from CLI console , Kafka Gives below error -
LEADER\_NOT\_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
Reason :
- Possibly the Kafka producer is trying to identify the leader for a given partition . In this process it tries to access below two property flags and tries to connect to them . However if these settings are not configured correctly it then may think that the leader is unavailable.
advertised.host.name
advertised.port
- Please note - if advertised.host.name is not configured , Kafka will use host.name. And the host.name is configured in server.properties file.
Fix 1 - For Local Set-up :
- Make below changes to the server.properties file
port = 9092
advertised.host.name = localhost or 127.0.0.1
advertised.listeners=PLAINTEXT://YOUR\_IP:9092
listeners = PLAINTEXT://0.0.0.0:9092
Fix 2: Multi Node Setup :
advertised.listeners=PLAINTEXT://Kafka\_IP:9092
listeners = PLAINTEXT://0.0.0.0:9092
Hope this helps - to Fix - Leader Not Available in Kafka Console Producer.
Additional Read -