# Error connecting to node kafka-broker:9092 (id: 1 rack: null) java.net.UnknownHostException: kafka-broker

**URL:** <https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434>\
**Category:** Logstash\
**Created:** [March 10, 2023, 10:03am UTC](https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434 "2023-03-10T10:03:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajesh\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajesh_r/32/113815_2.png) [@Rajesh\_R](https://discuss.elastic.co/u/Rajesh_R)\
**Post date:** [March 10, 2023, 10:03am UTC](https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434/1 "2023-03-10T10:03:59Z")

</div>

When I use kafka plugin in logstash, I am getting the below error.

[2023-03-10T15:11:46,310][WARN][org.apache.kafka.clients.NetworkClient][main][289f84d5c44d64af9505535a5352178af25a608c83252a1c520ab39a4faa4855] [Consumer clientId=logstash-0, groupId=logstash] Error connecting to node kafka-broker:9092 (id: 1 rack: null)  
java.net.UnknownHostException: kafka-broker

Yaml file :  
input {  
kafka {  
bootstrap\_servers =\> "localhost:9092"  
topics =\> ["topicdemo"]  
auto\_offset\_reset =\> "earliest"  
decorate\_events =\> true  
}  
}  
filter {

```
	}

```

output {  
elasticsearch {  
hosts =\> ["[https://localhost:9200](https://localhost:9200)"]  
cacert =\> 'C:\logstash-8.6.2-windows-x86\_64\logstash-8.6.2\config\http-cert\ca.crt'  
index =\> "topicdemo"  
user =\> "elastic"  
password =\> "\*\*\*\*\*\*\*\*"  
}  
}

---

<div class="post-metadata">

**Author:** ![Wave](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wave/32/117242_2.png) [@Wave](https://discuss.elastic.co/u/Wave)\
**Post date:** [March 23, 2023, 5:55pm UTC](https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434/2 "2023-03-23T17:55:59Z")

</div>

Looks like the program can't find the host called kafka-broker, but in your yaml file it is trying to bootstrap kafka on localhost right? Maybe try switching from kafka-broker to localhost? Just a guess.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [March 23, 2023, 6:52pm UTC](https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434/3 "2023-03-23T18:52:09Z")

</div>

I do not have kafka running these days, but it could be that the list of hosts for that topic in the bootstrap server has a hostname that logstash cannot resolve. Perhaps the bootstrap server should be configured to return an FQDN.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [March 23, 2023, 7:31pm UTC](https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434/4 "2023-03-23T19:31:43Z")

</div>

> [@Rajesh\_R](#):
>
> Error connecting to node kafka-broker:9092 (id: 1 rack: null)  
> java.net.UnknownHostException: kafka-broker

What is the `advertised.listeners` of your Kafka Cluster?

The `bootstrap_servers` in Logstash will get the the list of host from the configured server and this list will be the configured `advertised.listeners`, it is probably related to what @Badger mentioned.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 20, 2023, 7:32pm UTC](https://discuss.elastic.co/t/error-connecting-to-node-kafka-broker-9092-id-1-rack-null-java-net-unknownhostexception-kafka-broker/327434/5 "2023-04-20T19:32:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
