# Connection problem between Logstash and Elasticsearch running on Docker

**URL:** <https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757>\
**Category:** Logstash\
**Tags:** docker\
**Created:** [June 9, 2022, 6:00am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757 "2022-06-09T06:00:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Francesco66](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@Francesco66](https://discuss.elastic.co/u/Francesco66)\
**Post date:** [June 9, 2022, 6:00am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757/1 "2022-06-09T06:00:58Z")

</div>

```auto
Hello team,
I have a Logstash that I can successfully run and start by using the following docker command:
-------------------------
docker run --rm -d --name logstash-Casex -p 8080:8080 -p 8081:8081 -v /Logstash_custom_configs/config/pipelines.yml:/usr/share/logstash/config/pipelines.yml -v /Logstash_custom_configs/mycurated:/usr/share/logstash/zlda-pipeline-curated -v /Logstash_custom_configs/myraw:/usr/share/logstash/zlda-pipeline-raw -v /tmp:/tmp docker.elastic.co/logstash/logstash:7.12.0
---------------
Above Logstash reads the following output plugin where I have specified the target Elasticsearch:
--------
output {
    if [tags][0] == "pipeline" or [tags] == "pipeline" {
        elasticsearch {
            hosts => "9.30.118.124:9200"
            index => "zoa-%{sourceType}-%{host}-%{+YYYYMMdd}"
            pipeline => "%{sourceType}"
            }
            file {
                  path => "/tmp/test_outputIF_logstash.log"
                 }
    } else {
        elasticsearch {
            hosts => "9..30.118.124:9200"
            index => "zoa-%{sourceType}-%{host}-%{+YYYYMMdd}"
        }
        file {
                  path => "/tmp/test_outputELSE_logstash.log"
                 }
    }
}

on the same Linux server I run the target Elastic search using the following command:
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.0

So ES is lisetning at the adverised port 9200 or 9300.
Unluckily Logstash is not able tor each ES and I get the following error that persists even if I specified the following:
hosts => "0.0.0.0:9200"
-------------
[2022-06-09T05:56:02,967][WARN][logstash.outputs.elasticsearch][zlda-curated] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://0.0.0.0:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://0.0.0.0:9200/][Manticore::SocketException] Connection refused (Connection refused)"}
-------------
How can I make a successfull connection between LS and ES?
Thanks and bye

```

---

<div class="post-metadata">

**Author:** ![Francesco66](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@Francesco66](https://discuss.elastic.co/u/Francesco66)\
**Post date:** [June 9, 2022, 8:32am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757/2 "2022-06-09T08:32:02Z")

</div>

As additional information, let me add that ES is fully reachable at ip address 930.118.124 and port 9200 , at least according to the command below:  
.............  
root@truelove1:~# curl '[http://9.30.118.124:9200/\_cat/indices?v](http://9.30.118.124:9200/_cat/indices?v)'  
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size  
............  
Thanks

---

<div class="post-metadata">

**Author:** ![Francesco66](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@Francesco66](https://discuss.elastic.co/u/Francesco66)\
**Post date:** [June 9, 2022, 10:34am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757/3 "2022-06-09T10:34:20Z")

</div>

```auto
[quote="Francesco66, post:1, topic:306757"]
`[2022-06-09T05:56:02,967][WARN][logstash.outputs.elasticsearch][zlda-curated] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://0.0.0.0:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://0.0.0.0:9200/][Manticore::SocketException] Connection refused (Connection refused)"}`
[/quote]

```

---

<div class="post-metadata">

**Author:** ![Francesco66](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@Francesco66](https://discuss.elastic.co/u/Francesco66)\
**Post date:** [June 9, 2022, 10:35am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757/4 "2022-06-09T10:35:10Z")

</div>

```auto
I have also trried to specify elasticsearch that this the name of my ES container but no success...
[2022-06-09T10:30:48,860][WARN][logstash.outputs.elasticsearch][zlda-curated] Attempted to resurrect connection to dead ES instance, but got an error. {:url=>"http://elasticsearch:9200/", :error_type=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError, :error=>"Elasticsearch Unreachable: [http://elasticsearch:9200/][Manticore::ResolutionFailure] elasticsearch"}

```

---

<div class="post-metadata">

**Author:** ![Francesco66](https://avatars.discourse-cdn.com/v4/letter/f/e5b9ba/32.png) [@Francesco66](https://discuss.elastic.co/u/Francesco66)\
**Post date:** [June 9, 2022, 11:24am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757/5 "2022-06-09T11:24:15Z")

</div>

```auto
As additional test I entered into my Logstash docker container and I am able to reach Elasticsearch even to its external address and port as per following:
-----------
root@truelove1:~# docker exec -ti logstash-Casex bash
bash-4.2$ curl 'http://9.30.118.124:9200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
----------
cannot understand why when I pass 9.30.118.124 and 9200 in elasitchsearch-->hosts that doesn't work...

```

---

<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 7, 2022, 11:25am UTC](https://discuss.elastic.co/t/connection-problem-between-logstash-and-elasticsearch-running-on-docker/306757/6 "2022-07-07T11:25:12Z")

</div>

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