Connection problem between Logstash and Elasticsearch running on Docker

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

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'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
............
Thanks

[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]
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"}
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...

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