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]

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:

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:

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:

# 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
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

As mentioned in the doc, 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 example to get services up quickly.

1 Like

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:

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"]