# Filebeat to kafka: Failed to connect to broker

**URL:** https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440
**Category:** Beats
**Created:** [June 10, 2020, 6:14am UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440 "2020-06-10T06:14:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![charles97](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/charles97/32/79243_2.png) [@charles97](https://discuss.elastic.co/u/charles97)
#### Post date: [June 10, 2020, 6:14am UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440/1 "2020-06-10T06:14:02Z")

</div>

## environment :

1. kafka 2.11 (installed via ambari)
2. filebeat 7.4.2 (windows)

according this [source](https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.5/administration/content/kafka-ports.html) since it was installed via ambari i should use port 6667

## here is my filebeat.conf

```auto
filebeat.inputs:
    - type: log
      paths:
       - C:/Users/A/Desktop/DATA/mailbox3.csv
output.kafka:
  hosts: ["x.x.x.x:6667"]
  topic: "test"
  partition.round_robin:
    reachable_only: false
  required_acks: 1
  compression: gzip
  max_message_bytes: 1000000

```

## result

```auto
2020-06-10T09:18:01.448+0700 INFO kafka/log.go:53 client/metadata fetching metadata for [test] from broker x.x.x.x:6667

2020-06-10T09:18:01.450+0700 INFO kafka/log.go:53 producer/broker/1001 starting up

2020-06-10T09:18:01.451+0700 INFO kafka/log.go:53 producer/broker/1001 state change to [open] on test/0

2020-06-10T09:18:01.451+0700 INFO kafka/log.go:53 producer/leader/test/0 selected broker 1001

2020-06-10T09:18:01.451+0700 INFO kafka/log.go:53 Failed to connect to broker x.x.x.x:6667: dial tcp: lookup x.x.x.x: no such host

2020-06-10T09:18:01.452+0700 INFO kafka/log.go:53 producer/broker/1001 state change to [closing] because dial tcp: lookup x.x.x.x: no such host

2020-06-10T09:18:01.453+0700 DEBUG [kafka] kafka/client.go:264 finished kafka batch
2020-06-10T09:18:01.453+0700 DEBUG [kafka] kafka/client.go:278 Kafka publish failed with: dial tcp: lookup x.x.x.x: no such host
2020-06-10T09:18:01.454+0700 INFO kafka/log.go:53 producer/leader/test/0 state change to [flushing-3]

2020-06-10T09:18:01.456+0700 INFO kafka/log.go:53 producer/leader/test/0 state change to [normal]

2020-06-10T09:18:01.456+0700 INFO kafka/log.go:53 producer/leader/test/0 state change to [retrying-3]

2020-06-10T09:18:01.456+0700 INFO kafka/log.go:53 producer/leader/test/0 abandoning broker 1001

2020-06-10T09:18:01.456+0700 INFO kafka/log.go:53 producer/broker/1001 shut down

```

this problem similiar to this [source](https://discuss.elastic.co/t/we-are-not-receiving-the-logs-from-filebeat-to-kafka/178756) but i dont understand how to solve mine.  
Thank you

---

<div class="post-metadata">

### Author: ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)
#### Post date: [June 10, 2020, 8:17pm UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440/2 "2020-06-10T20:17:58Z")

</div>

Using the Kafka commandline client are you able to connect to `x.x.x.x:6667` from the same host where Filebeat is running? Knowing this would help us narrow down the issue.

Shaunak

---

<div class="post-metadata">

### Author: ![charles97](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/charles97/32/79243_2.png) [@charles97](https://discuss.elastic.co/u/charles97)
#### Post date: [June 11, 2020, 2:03am UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440/3 "2020-06-11T02:03:28Z")

</div>

Hi, thank you for your respond. Filebeat set on client pc, and kafka is in server pc. I've make sure filebeat able to see kafka pc by pinging client to kafka server

---

<div class="post-metadata">

### Author: ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)
#### Post date: [June 11, 2020, 2:34am UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440/4 "2020-06-11T02:34:59Z")

</div>

It's good that you can ping the kafka server. Next step would be to try and connect to the Kafka broker itself from your client PC, the same one where Filebeat is installed. Kafka provides command-line utilities for this. Can you try that and post the results here, please?

Thanks,

Shaunak

---

<div class="post-metadata">

### Author: ![charles97](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/charles97/32/79243_2.png) [@charles97](https://discuss.elastic.co/u/charles97)
#### Post date: [June 11, 2020, 3:29am UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440/5 "2020-06-11T03:29:28Z")

</div>

Dead Shaunak,  
thank you so much for your assistance i appreciate it so much, i've solved my problem by doing this:  
following this source [kafka listeners](https://rmoff.net/2018/08/02/kafka-listeners-explained/), since producers came from different environment of kafka server i need to edit server.properties and add advertised.listeners. So i added advertised.listeners the same as listeners which is `PLAINTEXT://hostname:6667`. It still doesnt` work`. So i change both of **hostname** into **IP** as `PLAINTEXT://IP:6667`. And it finally works.  
Once again thank you so much for your assistance.

Regards,  
Charles

---

<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: [July 9, 2020, 5:29am UTC](https://discuss.elastic.co/t/filebeat-to-kafka-failed-to-connect-to-broker/236440/6 "2020-07-09T05:29:36Z")

</div>

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