Problem phenomenon:
Today, I wanted to debug the service on my computer. I found that when calling the interface through the gateway, an error related to Kafka was reported, as follows:
java.net.UnknownHostException: kafkahost
Problem analysis:
It can be seen from the error message that the host named kafkahost cannot be recognized.
By viewing the configuration of a service instance of Kafka cluster configuration on Linux server, you can find:
listeners=PLAINTEXT://kafkahost:0091
This configuration uses the {kafkahost} mentioned in the error message. You can see that this service instance listens to the IP port} kafkahost: 0091; By viewing the/etc/hosts file of the Linux server, you can see:
Kafkahost points to the Linux server IP.
Since I accessed the Kafka service on the Linux server in the native service, I naturally could not resolve to kafkahost. Therefore, you need to add the corresponding configuration in the hosts file of this machine!
Solution:
Find the hosts file path of this machine:
C:\Windows\System32\drivers\etc
Add the following configuration at the end of the file to identify kafkahost as the Linux server IP:
Restart the local service and call the interface again without any error:
Read More:
- [Solved] kafka Error: java.net.UnknownHostException: ls-bptysztw
- [Solved] openstack4j Startup Error: java.net.UnknownHostException: controller
- kakfa Create topic Error: java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 3 larger than available brokers: 2.
- jemter java.net.BindException:Address alreardy in use [How to Solve]
- [Solved] Kafka in Windows error:java. nio. file. Filesystemexception: this file is in use by another program and cannot be accessed by the process
- [Solved] Kafka Error: Discovered coordinator XXXXX:9092 (id: 2147483647 rack: null) for group itstyle.
- [Solved] Tomcat configurate HTTPS error: java.net.SocketException: Permission denied
- [Solved] hadoop Error: 9000 failed on connection exception java.net.ConnectException Denied to Access
- JAVA Error Illegal access: this web application instance has been stopped already. Could not load net.sf
- [Solved] Error: caused by: java.net.bindexception: the address is already in use
- [Solved] port (127.0.0.1:64444): java.net.SocketException “Interrupted function call: accept failed“
- java.net.SocketException: software caused connection abort: socket write error resolution (selenium)
- [Solved] Hadoop failed on connection exception: java.net.ConnectException: Connection refused
- [Solved] failed on connection exception: java.net.ConnectException: Connection denied
- [Solved] Multithreading uses jsch to obtain a session for connection error: session.connect: java.net.socketexception: connection reset
- [Solved] Kafka Error: is/are not present and missingTopicsFatal is true
- [Solved] kafka startup Error: ERROR Fatal error during KafkaServer startup. Prepare to shutdown
- kafka Environment Build and Startup Error: ERROR [KafkaServer id=1] Fatal error during KafkaServer startup. Prepare to shutdown
- [Solved] Spring Kafka Send Error in specifies partition: Topic radar not present in metadata after 60000
- Java uses class array to report error Exception in thread “main” java.lang.NullPointerException solution