Ali Zeinali
Ali Zeinali

Reputation: 571

ElasticSearch Unable to revive connection: http://elasticsearch:9200/

I tried to run ELK on Centos 8 with docker-compose :

here my docker-compose.yml

version: '3.1'

services:

  elasticsearch:
   image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
   container_name: elasticsearch
   hostname: elasticsearch
   ports:
    - "9200:9200"
   expose:
    - "9200"
   volumes:
    - elasticsearch-data:/usr/share/elasticsearch/data
   networks:
    - docker-network

  kibana:
   image: docker.elastic.co/kibana/kibana:6.2.4
   container_name: kibana
   ports:
    - "5601:5601"
   expose:
    - "5601"
   environment:
    - SERVER_NAME=kibana.localhost
    - ELASTICSEARCH_URL=http://elasticsearch:9200
    - ELASTICSEARCH_USERNAME=elastic
    - ELASTICSEARCH_HOST=elasticsearch
    - ELASTICSEARCH_PORT=9200
    - ELASTIC_PWD=changeme
    - KIBANA_PWD=changeme
   depends_on:
    - elasticsearch
   networks:
    - docker-network

networks:
  docker-network:
    driver: bridge

volumes:
  elasticsearch-data:

but i'm facing with this error :

{"type":"log","@timestamp":"2020-03-03T22:53:19Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}

while i checked:

  1. elasticsearch is running fine.

  2. docker exec kibana ping elasticsearch work fine.

  3. both kibana and elasticsearch are on same network as you can see in docker-compose.yml

  4. i checked docker exec kibana curl http://elasticsearch:9200 and result is :

Failed connect to elasticsearch:9200; No route to host

I also check other similar problems and their solution but none of them worked.

Upvotes: 0

Views: 2021

Answers (1)

James McGuigan
James McGuigan

Reputation: 8106

If you are running ElasticSearch inside Docker, then you may need to check if you have allocated sufficient memory limits to Docker. This can cause ElasticSearch to slowdown and even crash.

By default Docker Desktop is set to allow 2Gb of RAM per Docker, but in my own project I found that 4Gb prevented crashing, but 5Gb produced an additional performance speedup. Your mileage may vary depending on the amount of data you are ingesting.

Docker Desktop memory settings can be set via:

  • Docker Desktop -> Preferences -> Resources -> Memory

To inspect memory usage within the Docker container

DOCKER_ID=`docker ps | tail -n1 | awk '{ print $1 }'`; docker exec -it $DOCKER_ID /bin/bash

free -h  # repeatedly run to inspect changes over time

Note that ElasticSearch memory usage peaks during ingest and indexing and then eventually settle down to a slightly lower number once indexing and consolidation is complete. So ideally peak memory usage should be tested during ingest.

Upvotes: 1

Related Questions