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

**URL:** <https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754>\
**Category:** Elasticsearch\
**Created:** [May 13, 2019, 7:29am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754 "2019-05-13T07:29:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![senthilgsk](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@senthilgsk](https://discuss.elastic.co/u/senthilgsk)\
**Post date:** [May 13, 2019, 7:29am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754/1 "2019-05-13T07:29:12Z")

</div>

I am using Docker. The elasticsearch and kibana containers are running.  
When I tried curl [http://192.168.99.100](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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 13, 2019, 9:38am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754/2 "2019-05-13T09:38:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![senthilgsk](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@senthilgsk](https://discuss.elastic.co/u/senthilgsk)\
**Post date:** [May 13, 2019, 1:11pm UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754/3 "2019-05-13T13:11:55Z")

</div>

My docker-compose.yml file have the following:

```auto
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**

```auto
{"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** :

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

```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 20, 2019, 10:01am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754/4 "2019-05-20T10:01:10Z")

</div>

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:

```auto
ELASTIC_VERSION=7.0.1
ELASTIC_SECURITY=true
ELASTIC_PASSWORD=changeme

```

`docker-compose.yml`:

```auto
---
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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 17, 2019, 10:01am UTC](https://discuss.elastic.co/t/curl-7-failed-to-connect-to-localhost-port-9200-connection-refused-docker/180754/5 "2019-06-17T10:01:24Z")

</div>

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