Curl: (7) Failed to connect to localhost port 9200: Connection refused - Docker

I am using Docker. The elasticsearch and kibana containers are running.
When I tried curl http://192.168.99.100, I am getting error
curl: (7) Failed to connect to localhost port 9200: Connection refused

I tried browsing the posts on the same topic but I could not get any solution.
Please help.

What are the elasticsearch logs?
What is the Dockerfile?
How do you start it?

My docker-compose.yml file have the following:

elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.0.1
    container_name: es01
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - xpack.security.enabled=true
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - edgex-network
  kibana:
    image: docker.elastic.co/kibana/kibana:7.0.1
    container_name: kibana
    environment:
      - XPACK_SECURITY_ENABLED=true
      - SERVER_NAME=kibana
      - SERVR_HOST=0
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
      - XPACK_MONITORING_UI_CONTAINER_ELASTICSEARCH_ENABLED=true
    ports: 
      - 5601:5601
    networks: 
      - edgex-network
    depends_on: 
      - elasticsearch

Logs from kibana Container

{"type":"log","@timestamp":"2019-05-13T12:58:41Z","tags":["status","plugin:elasticsearch@undefined","error"],"pid":1,"state":"red","message":"Status changed from red to red - Request Timeout after 3000ms","prevState":"red","prevMsg":"Unable to connect to Elasticsearch."}
{"type":"log","@timestamp":"2019-05-13T12:59:50Z","tags":["warning","elasticsearch","data"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}

Logs from Elastic Search Container:

{"type":"log","@timestamp":"2019-05-13T12:59:50Z","tags":["warning","elasticsearch","data"],"pid":1,"message":"Unable to revive connection: http://elasticsearch:9200/"}

I tried to run you docker-compose.yml example but nothing starts.
Getting some errors, due to formatting I guess.

Here is anyway what I'm using on my side:

.env file:

ELASTIC_VERSION=7.0.1
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=changeme

docker-compose.yml:

---
version: '3'
services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:$ELASTIC_VERSION
    environment:
      - bootstrap.memory_lock=true
      - discovery.type=single-node
      - cluster.name=elasticsearch
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
      - cluster.routing.allocation.disk.threshold_enabled=false
      - xpack.license.self_generated.type=trial
      - xpack.security.enabled=$ELASTIC_SECURITY
      - ELASTIC_PASSWORD=$ELASTIC_PASSWORD
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9200:9200
      - 9300:9300
    networks: ['stack']

  kibana:
    image: docker.elastic.co/kibana/kibana:$ELASTIC_VERSION
    environment:
      - ELASTICSEARCH_USERNAME=elastic
      - ELASTICSEARCH_PASSWORD=$ELASTIC_PASSWORD
    ports: ['5601:5601']
    networks: ['stack']
    links: ['elasticsearch']
    depends_on: ['elasticsearch']

networks:
  stack: {}

HTH

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