解决:Kafka 报错 java.io.IOException: Can‘t resolve address: iZuf65paliafsmaw29vb8jZ:9092

今天在自己的服务器上装了一个Kafka,在自己电脑上使用springboot集成kafka,发送消息的时候,报了下面的错误:

[customer] 2020-08-13 16:23:32.984 WARN  [kafka-producer-network-thread | producer-1] [NetworkClient                 ] [Producer clientId=producer-1] Error connecting to node iZuf65paliafsmaw29vb8jZ:9092 (id: 0 rack: null)java.io.IOException: Can't resolve address: iZuf65paliafsmaw29vb8jZ:9092
	at org.apache.kafka.common.network.Selector.doConnect(Selector.java:235)
	at org.apache.kafka.common.network.Selector.connect(Selector.java:214)
	at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:864)
	at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:265)
	at org.apache.kafka.clients.producer.internals.Sender.sendProducerData(Sender.java:266)
	at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:238)
	at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:163)
	at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.nio.channels.UnresolvedAddressException: null
	at java.base/sun.nio.ch.Net.checkAddress(Net.java:130)
	at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:675)
	at org.apache.kafka.common.network.Selector.doConnect(Selector.java:233)
	... 7 common frames omitted
 - org.apache.kafka.clients.NetworkClient - NetworkClient.java:873
java.io.IOException: Can't resolve address: iZuf65paliafsmaw29vb8jZ:9092
	at org.apache.kafka.common.network.Selector.doConnect(Selector.java:235)
	at org.apache.kafka.common.network.Selector.connect(Selector.java:214)
	at org.apache.kafka.clients.NetworkClient.initiateConnect(NetworkClient.java:864)
	at org.apache.kafka.clients.NetworkClient.ready(NetworkClient.java:265)
	at org.apache.kafka.clients.producer.internals.Sender.sendProducerData(Sender.java:266)
	at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:238)
	at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:163)
	at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.nio.channels.UnresolvedAddressException: null
	at java.base/sun.nio.ch.Net.checkAddress(Net.java:130)
	at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:675)
	at org.apache.kafka.common.network.Selector.doConnect(Selector.java:233)
	... 7 common frames omitted

从报错内容中可以看到,是因为无法解析 iZuf65paliafsmaw29vb8jZ 这个地址造成的,那么我们只需要在hosts文件中添加:

101.130.125.17 iZuf65paliafsmaw29vb8jZ

Mac中hosts文件路径:/private/etc/hosts,如果提示没有权限,则将hosts复制出来,修改完了再粘贴过去覆盖就好啦。

101.130.125.17是我的服务器的地址,iZuf65paliafsmaw29vb8jZ是报错里无法解析的地址。

改完之后再试一次就OK啦!

©️2020 CSDN 皮肤主题: 点我我会动 设计师:上身试试 返回首页