Search code examples
apache-kafkakafka-consumer-apikafka-producer-api

Kafka broker is not available from localhost


I have installed kafka_2.11-1.1.0 and set advertised listener to advertised.listeners=PLAINTEXT://<my-ip>:9092 (in $KAFKA_HOME/config/server.properties).

I can connect and write to my kafka using java code and see my cluster via kafka-tool from another server but I can't write messages to my topic from my local machine (the one that I have installed kafka cluster on it).

I have also tried to set listeners value to listeners = PLAINTEXT://:9092 but there is no change. What should I do to my kafka to make it reachable and writable from both outside and inside of the localhost?


Solution

  • I finally solved the issue by changing my code's org.apache.kafka library from version 1.1.0 to version 2.1.0.

    I mention that all of these libraries were imported (downloaded) and used via mvnrepository.com.

    Also, our kafka producer and consumer code pattern were written using this article: https://dzone.com/articles/kafka-producer-and-consumer-example.