Elastic is not running on port 9200

Hello, l started Elasticsearch using docker-compose.yml:

version: '2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:5.6.16
    container_name: elasticsearch
    restart: unless-stopped
    environment:
      - "network.host=127.0.0.1"
      - "http.port=9200"
      - "cluster.name=elasticsearch"
      - "node.name=\"db-master\""
      - "node.master=true"
      - "node.data=true"
      - "bootstrap.memory_lock=true"
      - "ES_JAVA_OPTS=-Xms1g -Xmx1g"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: 2g
    volumes:
      - esdata:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - esnet

volumes:
  esdata:
    driver: local

networks:
  esnet:

This is output from docker container ls:

CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS                              NAMES
a2ddd5cee8dc        docker.elastic.co/elasticsearch/elasticsearch:5.6.16   "/bin/bash bin/es-do…"   12 hours ago        Up 12 hours         0.0.0.0:9200->9200/tcp, 9300/tcp   elasticsearch

But I cannot access it from console like curl -XGET 'localhost:9200', I get:

curl: (56) Recv failure: Connection reset by peer

I would like to know where is a problem.

Change network host to 0.0.0.0 as 127.0.0.1 is only available from within the container.

But it listens on all addresses, I don't want to be it reachable from internet, because it is going to be running on production server, so I want to bind it to localhost only.

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