# Kafka Logstash Plugin unavailable broker (swaps broker addresses for discovery?)

**URL:** https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220
**Category:** Logstash
**Tags:** docker
**Created:** [November 9, 2019, 7:53pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220 "2019-11-09T19:53:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jbpratt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbpratt/32/57424_2.png) [@jbpratt](https://discuss.elastic.co/u/jbpratt)
#### Post date: [November 9, 2019, 7:53pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/1 "2019-11-09T19:53:27Z")

</div>

Hey everyone,

I'm pretty new to the stack and ran into some issues with trying to use a Kafka input. Here is my logstash.conf and logs from attaching to the container. In the logs, it successfully subscribes to the topics, then just starts failing with the unavailable broker error for the local address which is not what is set. Any help would be appreciated 🙂

```auto
input {
  kafka {
    bootstrap_servers => "kafka11:9092,kafka12:9093"
    topics => ["messages", "jq"]
  }
}

```

```auto
logstash_1 | [2019-11-09T19:41:41,081][INFO][org.apache.kafka.common.utils.AppInfoParser] Kafka version: 2.3.0
logstash_1 | [2019-11-09T19:41:41,081][INFO][org.apache.kafka.common.utils.AppInfoParser] Kafka commitId: fc1aaa116b661c8a
logstash_1 | [2019-11-09T19:41:41,082][INFO][org.apache.kafka.common.utils.AppInfoParser] Kafka startTimeMs: 1573328501071
logstash_1 | [2019-11-09T19:41:41,196][INFO][org.apache.kafka.clients.consumer.KafkaConsumer] [Consumer clientId=logstash-0, groupId=logstash] **Subscribed to topic(s): messages, jq**
logstash_1 | [2019-11-09T19:41:42,588][WARN][logstash.outputs.elasticsearch] You are using a deprecated config setting "document_type" set in elasticsearch. Deprecated settings will continue to work, but are scheduled for removal from logstash in the future. Document types are being deprecated in Elasticsearch 6.0, and removed entirely in 7.0. You should avoid this feature If you have any questions about this, please visit the #logstash channel on freenode irc. {:name=>"document_type", :plugin=><LogStash::Outputs::ElasticSearch bulk_path=>"/_monitoring/bulk?system_id=logstash&system_api_version=7&interval=1s", password=><password>, hosts=>[http://elasticsearch:9200], sniffing=>false, manage_template=>false, id=>"61217436ba74368dd34f5b7464eeea6e43d6b014cfc9e111093960789f46ecd1", user=>"elastic", document_type=>"%{[@metadata][document_type]}", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_342629a8-9da9-400f-939d-67e1a383589b", enable_metric=>true, charset=>"UTF-8">, workers=>1, template_name=>"logstash", template_overwrite=>false, doc_as_upsert=>false, script_type=>"inline", script_lang=>"painless", script_var_name=>"event", scripted_upsert=>false, retry_initial_interval=>2, retry_max_interval=>64, retry_on_conflict=>1, ilm_enabled=>"auto", ilm_rollover_alias=>"logstash", ilm_pattern=>"{now/d}-000001", ilm_policy=>"logstash-policy", action=>"index", ssl_certificate_verification=>true, sniffing_delay=>5, timeout=>60, pool_max=>1000, pool_max_per_route=>100, resurrect_delay=>5, validate_after_inactivity=>10000, http_compression=>false>}
logstash_1 | [2019-11-09T19:41:42,840][INFO][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://elastic:xxxxxx@elasticsearch:9200/]}}
logstash_1 | [2019-11-09T19:41:42,918][WARN][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"http://elastic:xxxxxx@elasticsearch:9200/"}
logstash_1 | [2019-11-09T19:41:42,957][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Error while fetching metadata with correlation id 2 : {jq=LEADER_NOT_AVAILABLE, messages=LEADER_NOT_AVAILABLE}
logstash_1 | [2019-11-09T19:41:42,961][INFO][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>7}
logstash_1 | [2019-11-09T19:41:42,961][WARN][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>7}
logstash_1 | [2019-11-09T19:41:43,047][INFO][org.apache.kafka.clients.Metadata] [Consumer clientId=logstash-0, groupId=logstash] Cluster ID: d9PMTWr7Tc6deRqSpRZHSw
logstash_1 | [2019-11-09T19:41:43,079][INFO][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["http://elasticsearch:9200"]}
logstash_1 | [2019-11-09T19:41:43,177][INFO][logstash.javapipeline] Starting pipeline {:pipeline_id=>".monitoring-logstash", "pipeline.workers"=>1, "pipeline.batch.size"=>2, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>2, :thread=>"#<Thread:0x6850ed28 run>"}
logstash_1 | [2019-11-09T19:41:43,197][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 3 (/127.0.0.1:9094) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,236][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 2 (/127.0.0.1:9093) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,310][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 1 (/127.0.0.1:9092) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,311][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 3 (/127.0.0.1:9094) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,311][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 2 (/127.0.0.1:9093) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,373][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 1 (/127.0.0.1:9092) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,430][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 3 (/127.0.0.1:9094) could not be established. Broker may not be available.
logstash_1 | [2019-11-09T19:41:43,460][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 2 (/127.0.0.1:9093) could not be established. Broker may not be available.
...
logstash_1 | [2019-11-09T19:41:43,713][INFO][logstash.javapipeline] Pipeline started {"pipeline.id"=>".monitoring-logstash"}
logstash_1 | [2019-11-09T19:41:43,759][INFO][logstash.agent] Pipelines running {:count=>2, :running_pipelines=>[:main, :".monitoring-logstash"], :non_running_pipelines=>[]}
logstash_1 | [2019-11-09T19:41:43,837][WARN][org.apache.kafka.clients.NetworkClient] [Consumer clientId=logstash-0, groupId=logstash] Connection to node 2 (/127.0.0.1:9093) could not be established. Broker may not be available.
^CGracefully stopping... (press Ctrl+C again to force)

```

---

<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: [November 9, 2019, 8:17pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/2 "2019-11-09T20:17:12Z")

</div>

What is advertised.listeners set to?

---

<div class="post-metadata">

### Author: ![jbpratt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbpratt/32/57424_2.png) [@jbpratt](https://discuss.elastic.co/u/jbpratt)
#### Post date: [November 9, 2019, 8:32pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/3 "2019-11-09T20:32:17Z")

</div>

```auto
 environment:
      KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka11:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092

```

So this is from my docker-compose file, found online and have modified quite a bit. I see that the `LISTENER_DOCKER_EXTERNAL` ends up defaulting to the loopback address I assume? I just attempted swapping it to be the hostname setup but that leads to DNS resolution errors. Please let me know what else I can provide that may be of help. [Here](https://github.com/simplesteph/kafka-stack-docker-compose/blob/c1a40f44c22f084e1d248d5b2732ec01c77afb55/zk-multiple-kafka-multiple.yml#L50) is an example of my compose file, I have just extended it with numerous other services.

---

<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: [November 9, 2019, 8:52pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/4 "2019-11-09T20:52:23Z")

</div>

Unfortunately I do not know docker, so I do not know how to get the correct IP address in there.

---

<div class="post-metadata">

### Author: ![jbpratt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbpratt/32/57424_2.png) [@jbpratt](https://discuss.elastic.co/u/jbpratt)
#### Post date: [November 9, 2019, 8:54pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/5 "2019-11-09T20:54:42Z")

</div>

No worries, thank you for your time! This setup is mostly just for local testing anyway, hopefully I won't run into this when I move into a different stage.

---

<div class="post-metadata">

### Author: ![jbpratt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbpratt/32/57424_2.png) [@jbpratt](https://discuss.elastic.co/u/jbpratt)
#### Post date: [November 9, 2019, 9:23pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/6 "2019-11-09T21:23:05Z")

</div>

I think I figured it out, my network was setup wrong so that was the first issue. Then changing the `LISTENER_DOCKER_EXTERNAL` to be the hostname of the container ended up working. Thanks for your time!

---

<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: [December 7, 2019, 9:23pm UTC](https://discuss.elastic.co/t/kafka-logstash-plugin-unavailable-broker-swaps-broker-addresses-for-discovery/207220/7 "2019-12-07T21:23:10Z")

</div>

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