Kafka consumer fetching metadata for topics failed
The broker tells the client which hostname should be used to produce/consume messages. By default Kafka uses the hostname of the system it runs on. If this hostname can not be resolved by the client side you get this exception.
You can try setting advertised.host.name
in the Kafka configuration to an hostname/address which the clients should use.
Here is my way to solve this problem:
- run
bin/kafka-server-stop.sh
to stop running kafka server. - modify the properties file
config/server.properties
by adding a line:listeners=PLAINTEXT://{ip.of.your.kafka.server}:9092
- restart kafka server.
Since without the lisener setting, kafka will use java.net.InetAddress.getCanonicalHostName()
to get the address which the socket server listens on.