# Xiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: \[error connecting to Elasticsearch at http://127.0.0.1:9200: Get "http://127.0.0.1:9200": dial tcp 127.0.0.1:9200: connect: connection refused\]

**URL:** https://discuss.elastic.co/t/xiting-couldnt-connect-to-any-of-the-configured-elasticsearch-hosts-errors-error-connecting-to-elasticsearch-at-http-127-0-0-1-get-http-127-0-0-1-9200-dial-tcp-127-0-0-1-connect-connection-refused/359981
**Category:** Beats
**Tags:** elastic-stack-security, docker, filebeat
**Created:** [May 22, 2024, 10:00am UTC](https://discuss.elastic.co/t/xiting-couldnt-connect-to-any-of-the-configured-elasticsearch-hosts-errors-error-connecting-to-elasticsearch-at-http-127-0-0-1-get-http-127-0-0-1-9200-dial-tcp-127-0-0-1-connect-connection-refused/359981 "2024-05-22T10:00:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tohkoecalo](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tohkoecalo](https://discuss.elastic.co/u/tohkoecalo)
#### Post date: [May 22, 2024, 10:00am UTC](https://discuss.elastic.co/t/xiting-couldnt-connect-to-any-of-the-configured-elasticsearch-hosts-errors-error-connecting-to-elasticsearch-at-http-127-0-0-1-get-http-127-0-0-1-9200-dial-tcp-127-0-0-1-connect-connection-refused/359981/1 "2024-05-22T10:00:30Z")

</div>

Hi All,  
I try to run elasticsearch, kibana and filebeat as docker containers but got a problem. I receive a connection refused message while starting filebeat container. My startup command is:

```auto
docker run docker.elastic.co/beats/filebeat:8.13.4 setup -E setup.kibana.host=127.0.0.1:5601 -E output.elasticsearch.hosts=["127.0.0.1:9200"]

```

The error message is:

```auto
Exiting: couldn't connect to any of the configured Elasticsearch hosts. Errors: [error connecting to Elasticsearch at http://127.0.0.1:9200: Get "http://127.0.0.1:9200": dial tcp 127.0.0.1:9200: connect: connection refused]

```

Here is my .env and docker-compose.yaml files to start elasticsearch and kibana containers:

```auto
# Password for the 'elastic' user (at least 6 characters)
ELASTIC_PASSWORD=elastic

# Password for the 'kibana_system' user (at least 6 characters)
KIBANA_PASSWORD=kibana

# Version of Elastic products
STACK_VERSION=8.13.4

# Set the cluster name
CLUSTER_NAME=docker-cluster

# Set to 'basic' or 'trial' to automatically start the 30-day trial
LICENSE=basic
#LICENSE=trial

# Port to expose Elasticsearch HTTP API to the host
ES_PORT=9200
#ES_PORT=127.0.0.1:9200

# Port to expose Kibana to the host
KIBANA_PORT=5601
#KIBANA_PORT=80

# Increase or decrease based on the available host memory (in bytes)
MEM_LIMIT=1073741824

# Project namespace (defaults to the current folder name if not set)
#COMPOSE_PROJECT_NAME=myproject

```

```auto
version: "2.2"

services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}
    volumes:
      - esdata01:/usr/share/elasticsearch/data
    ports:
      - ${ES_PORT}:9200
    environment:
      - node.name=es01
      - cluster.name=${CLUSTER_NAME}
      - cluster.initial_master_nodes=es01
      - discovery.seed_hosts=es02
      - ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
      - xpack.security.enabled=false
      - xpack.security.http.ssl.enabled=false
    ulimits:
      memlock:
        soft: -1
        hard: -1

  kibana:
    image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
    volumes:
      - kibanadata:/usr/share/kibana/data
    ports:
      - ${KIBANA_PORT}:5601
    environment:
      - SERVERNAME=kibana
      - ELASTICSEARCH_HOSTS=http://192.168.0.7:9200
      - ELASTICSEARCH_USERNAME=kibana_system
      - ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}

volumes:
  esdata01:
    driver: local
  kibanadata:
    driver: local

```

---

<div class="post-metadata">

### Author: ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)
#### Post date: [May 22, 2024, 11:02am UTC](https://discuss.elastic.co/t/xiting-couldnt-connect-to-any-of-the-configured-elasticsearch-hosts-errors-error-connecting-to-elasticsearch-at-http-127-0-0-1-get-http-127-0-0-1-9200-dial-tcp-127-0-0-1-connect-connection-refused/359981/2 "2024-05-22T11:02:17Z")

</div>

As mentioned in the [doc](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-compose-file), [docker-compose.yml](https://github.com/elastic/elasticsearch/blob/8.13/docs/reference/setup/install/docker/docker-compose.yml) is dfifferent. It is missing of commands, healthchecks etc.

Could you try with `docker-compose.yml` file which mentioned in the doc. It is multi node example but you can simply comment out the other services which you don't need.

Also you can refer [single-node-cluster](https://github.com/ashishtiwari1993/elastic-docker/tree/main) example to get services up quickly.

---

<div class="post-metadata">

### Author: ![tohkoecalo](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tohkoecalo](https://discuss.elastic.co/u/tohkoecalo)
#### Post date: [May 22, 2024, 11:05am UTC](https://discuss.elastic.co/t/xiting-couldnt-connect-to-any-of-the-configured-elasticsearch-hosts-errors-error-connecting-to-elasticsearch-at-http-127-0-0-1-get-http-127-0-0-1-9200-dial-tcp-127-0-0-1-connect-connection-refused/359981/3 "2024-05-22T11:05:32Z")

</div>

Hi, @ashishtiwari1993  
This is docker-compose from doc but I disabled SSL between elasticsearch and kibana and removed other nodes. For now I replaced kibana and elastic hosts to my host machine IP and filebeat started:

```auto
docker run docker.elastic.co/beats/filebeat:8.13.4 setup -E setup.kibana.host=192.168.0.7:5601 -E output.elasticsearch.hosts=["192.168.0.7:9200"]

```
