# Logstash docker container can not connect to the ElasticSearch (non-docker) on another host

**URL:** <https://discuss.elastic.co/t/logstash-docker-container-can-not-connect-to-the-elasticsearch-non-docker-on-another-host/269730>\
**Category:** Logstash\
**Created:** [April 9, 2021, 4:03pm UTC](https://discuss.elastic.co/t/logstash-docker-container-can-not-connect-to-the-elasticsearch-non-docker-on-another-host/269730 "2021-04-09T16:03:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kube-elk](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kube-elk](https://discuss.elastic.co/u/kube-elk)\
**Post date:** [April 9, 2021, 4:03pm UTC](https://discuss.elastic.co/t/logstash-docker-container-can-not-connect-to-the-elasticsearch-non-docker-on-another-host/269730/1 "2021-04-09T16:03:52Z")

</div>

Hi

I have 2 docker containers: filebeat and logstash which I run using docker-compose. I am trying to configure logstash such that it will write index to the Elasticsearch (non-docker) hosted on another node.

Here is my docker-compose file:

version: '3.5'

```auto
services:
  logstash:
    container_name: logstash
    build:
      context: logstash/
    restart: always
    environment: 
      LS_JAVA_OPTS: "-Xmx256m -Xms256m"
    ports:
    - 5044:5044
    - 9600:9600
    - 9200:9200

```

My logstash pipeline has following code in order to connect to the Elasticsearch:

```auto
output {
  elasticsearch {
    hosts => ["http://myelasticnode:9200"]
    user => "elastic"
    password => "elastic"
    index => "%{[%metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
}

```

I get an error: Attempted to resurrect connection to dead ES instance, but got an error. {url=\>[http://elastic:elastic@myelasticnode:9200/](http://elastic:elastic@myelasticnode:9200/)", error\_type=\>Logstash::Outputs::Elasticsearch::HttpClient::Pool::HostUnreachableError, :error=\>"Elasticsearch Unreachable. myelasticnode: Name or service not known"}

On the host where logstash docker container is running, I can curl to the elasticsearch node which gives a valid json output message. What do I need to do so that logstash docker container can communicate with Elasticsearch (not a docker container)?

Thanks in advance.  
Ram

---

<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:** [May 7, 2021, 4:04pm UTC](https://discuss.elastic.co/t/logstash-docker-container-can-not-connect-to-the-elasticsearch-non-docker-on-another-host/269730/2 "2021-05-07T16:04:52Z")

</div>

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