# Mapping ElasticSearch Port with ports: 92xx:9200 in Docker

**URL:** <https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359>\
**Category:** Kibana\
**Created:** [May 25, 2018, 7:36pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359 "2018-05-25T19:36:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisruel](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@chrisruel](https://discuss.elastic.co/u/chrisruel)\
**Post date:** [May 25, 2018, 7:36pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/1 "2018-05-25T19:36:33Z")

</div>

Is it possible to map the default port for an ElasticSearch docker container from 9200 to 92XX (i.e. 9222) or some other port using -

elasticsearch:  
image: [docker.elastic.co/elasticsearch/elasticsearch:6.2.4](http://docker.elastic.co/elasticsearch/elasticsearch:6.2.4)  
...  
ports:

- 92xx:9200

When I attempt to do this and connect using Kibana, Kibana will only connect if configured on port 9200, i.e. -\>  
ELASTICSEARCH\_URL=http://elasticsearch:9200

and  
ELASTICSEARCH\_URL=http://elasticsearch:96xx  
does not work.

docker container exec -i kibana curl elasticsearch:9200/\_cat/health  
returns a valid connection, even though the port should be remapped to 96xx.

docker container exec -i kibana curl elasticsearch:92xx/\_cat/health  
returns invalid connection data.

I have used docker container stop and rm to remove all prior container instances.

---

<div class="post-metadata">

**Author:** ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)\
**Post date:** [May 25, 2018, 8:14pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/2 "2018-05-25T20:14:21Z")

</div>

By default, Elasticsearch docker reserves the ports 9200 and 9300. [Example base Docker Compose file showing both ports.](https://github.com/deviantony/docker-elk/blob/master/docker-compose.yml)

To change the ports (to 9299 and 9399, for example), add:

```auto
    ports:
      - "9299:9200"
      - "9399:9300"

```

which maps custom outside port to regular ES inside port.

Then change Kibana configuration accordingly:

```auto
    environment:
      ELASTICSEARCH_URL: http://elasticsearch:9299

```

---

<div class="post-metadata">

**Author:** ![chrisruel](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@chrisruel](https://discuss.elastic.co/u/chrisruel)\
**Post date:** [May 25, 2018, 8:33pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/3 "2018-05-25T20:33:25Z")

</div>

I am getting the "No living connection" error at Kibana when I try to do the configuration according to your example and ES is not accessible from a browser at localhost:9299

---

<div class="post-metadata">

**Author:** ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)\
**Post date:** [May 25, 2018, 9:12pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/4 "2018-05-25T21:12:40Z")

</div>

Could you share your entire docker-compose.yml file?

---

<div class="post-metadata">

**Author:** ![chrisruel](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@chrisruel](https://discuss.elastic.co/u/chrisruel)\
**Post date:** [May 29, 2018, 2:20pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/5 "2018-05-29T14:20:55Z")

</div>

```
version: "3"

volumes:
elasticsearch-test-vol:

networks:
elasticsearch-test-net:

services:

elasticsearch-test-624-service:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    container_name: elasticsearch-test-624
    restart: always
    networks:
    - elasticsearch-test-net
    environment:
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - xpack.security.enabled=true
    ulimits:
        memlock:
            soft: -1
            hard: -1
    ports:
    - "9699:9699"
    expose:
    - "9699"
    volumes:
    - elasticsearch-test-vol:/usr/share/elasticsearch/data

kibana-test-624-service:
    image: docker.elastic.co/kibana/kibana:6.2.4
    container_name: kibana-test-624
    hostname: kibana
    restart: always
    networks:
    - elasticsearch-test-net
    environment:
    - SERVER_NAME=kibana.localhost
    - ELASTICSEARCH_URL=http://elasticsearch-test-624:9699
    - ELASTICSEARCH_USERNAME=elastic
    - ELASTICSEARCH_HOST=elasticsearch-test-624
    - ELASTICSEARCH_PORT=9699
    - ELASTIC_PWD=changeme
    - KIBANA_PWD=changeme
    ports:
    - "5699:5601"
    expose:
    - "5624"
    links:
    - elasticsearch-test-624-service
    depends_on:
    - elasticsearch-test-624-service
```

---

<div class="post-metadata">

**Author:** ![chrisruel](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@chrisruel](https://discuss.elastic.co/u/chrisruel)\
**Post date:** [May 29, 2018, 2:21pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/6 "2018-05-29T14:21:57Z")

</div>

kibana-test-624 | {"type":"log","@timestamp":"2018-05-29T14:11:48Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}  
kibana-test-624 | {"type":"log","@timestamp":"2018-05-29T14:11:51Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: [http://elasticsearch-test-624:9699/](http://elasticsearch-test-624:9699/)"}

---

<div class="post-metadata">

**Author:** ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)\
**Post date:** [June 8, 2018, 8:00pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/7 "2018-06-08T20:00:30Z")

</div>

Apologies for the late follow up. My previous post had incorrect information with regards to the ports. The mapping should be `HOST:CONTAINER`. I have edited my post as well.

So for your Elasticsearch service, it should be:

```auto
ports:
    - "9699:9200"

```

The rest of the configuration looks good.

(More about `ports` and `expose`: [https://stackoverflow.com/a/40801773](https://stackoverflow.com/a/40801773))

---

<div class="post-metadata">

**Author:** ![chrisruel](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@chrisruel](https://discuss.elastic.co/u/chrisruel)\
**Post date:** [June 11, 2018, 6:54pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/8 "2018-06-11T18:54:39Z")

</div>

I am getting errors when I try the following yml:

```
version: "3"

volumes:
elasticsearch-test-vol:

networks:
elasticsearch-test-net:

services:

elasticsearch-test-624-service:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    container_name: elasticsearch-test-624
    restart: always
    networks:
        - elasticsearch-test-net
    environment:
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - xpack.security.enabled=true
    ulimits:
        memlock:
            soft: -1
            hard: -1
    ports:
    - "9699:9200"
    expose:
    - "9699"
    volumes:
    - elasticsearch-test-vol:/usr/share/elasticsearch/data

kibana-test-624-service:
    image: docker.elastic.co/kibana/kibana:6.2.4
    container_name: kibana-test-624
    hostname: kibana
    restart: always
    networks:
    - elasticsearch-test-net
    environment:
    - SERVER_NAME=kibana.localhost
    - ELASTICSEARCH_URL=http://elasticsearch-test-624:9699
    - ELASTICSEARCH_USERNAME=elastic
    - ELASTICSEARCH_HOST=elasticsearch-test-624
    - ELASTICSEARCH_PORT=9699
    - ELASTIC_PWD=changeme
    - KIBANA_PWD=changeme
    - xpack.security.enabled=true
    ports:
    - "5699:5601"
    expose:
    - "5699"
    depends_on:
    - elasticsearch-test-624-service

```

The error messages are as follows:  
Kibana console:

```
Login is currently disabled. Administrators should consult the Kibana logs for more details.

```

Logs to stdout:

```
kibana-test-624 | {"type":"log","@timestamp":"2018-06-11T18:53:29Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"Unable to revive connection: http://elasticsearch-test-624:9699/"}
kibana-test-624 | {"type":"log","@timestamp":"2018-06-11T18:53:29Z","tags":["warning","elasticsearch","admin"],"pid":1,"message":"No living connections"}

$ docker-compose ps
     Name Command State Ports         
--------------------------------------------------------------------------------
elasticsearch-test-624 /usr/local/bin/docker- Up 0.0.0.0:9699->9200/tcp
                     entr ... , 9300/tcp, 9699/tcp  
kibana-test-624 /bin/bash Up 0.0.0.0:5699->5601/tcp
                     /usr/local/bin/k ... , 5699/tcp
```

---

<div class="post-metadata">

**Author:** ![chrisruel](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@chrisruel](https://discuss.elastic.co/u/chrisruel)\
**Post date:** [June 11, 2018, 7:00pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/9 "2018-06-11T19:00:01Z")

</div>

As a point of reference, the identical YML with the default port mapping to 9200:9200 works without errors reported... I am explicitly trying to get the port mappings working in this case.

```
version: "3"

volumes:
elasticsearch-test-vol:

networks:
elasticsearch-test-net:

services:

elasticsearch-test-624-service:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
    container_name: elasticsearch-test-624
    restart: always
    networks:
        - elasticsearch-test-net
    environment:
        - cluster.name=docker-cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - xpack.security.enabled=true
    ulimits:
        memlock:
            soft: -1
            hard: -1
    ports:
    - "9200:9200"
    expose:
    - "9200"
    volumes:
    - elasticsearch-test-vol:/usr/share/elasticsearch/data

kibana-test-624-service:
    image: docker.elastic.co/kibana/kibana:6.2.4
    container_name: kibana-test-624
    hostname: kibana
    restart: always
    networks:
    - elasticsearch-test-net
    environment:
    - SERVER_NAME=kibana.localhost
    - ELASTICSEARCH_URL=http://elasticsearch-test-624:9200
    - ELASTICSEARCH_USERNAME=elastic
    - ELASTICSEARCH_HOST=elasticsearch-test-624
    - ELASTICSEARCH_PORT=9200
    - ELASTIC_PWD=changeme
    - KIBANA_PWD=changeme
    - xpack.security.enabled=true
    ports:
    - "5699:5601"
    expose:
    - "5699"
    depends_on:
    - elasticsearch-test-624-service
```

---

<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:** [July 9, 2018, 7:00pm UTC](https://discuss.elastic.co/t/mapping-elasticsearch-port-with-ports-92xx-9200-in-docker/133359/10 "2018-07-09T19:00:03Z")

</div>

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