Can curl https://elasticsearch:9200 from host, but connection refused in kibana container

I have elasticsearch and kibana running on the same node in a swarm, connected to the same docker network.

From the node (host machine), I can curl https://elasticsearch:9200 and I get a response.
From inside the kibana container, when I run it, I get the following:

bash-4.2$ curl https://elasticsearch:9200
curl: (7) Failed connect to elasticsearch:9200; Connection refused

This is the cause of kibana not being able to connect to elasticsearch:

{"type":"log","@timestamp":"2020-04-17T19:21:44Z","tags":["warning","elasticsearch","admin"],"pid":6,"message":"Unable to revive connection: https://elasticsearch:9200/"}
{"type":"log","@timestamp":"2020-04-17T19:21:44Z","tags":["warning","elasticsearch","admin"],"pid":6,"message":"No living connections"}

Why can I not curl from kibana to elasticsearch?


elasticsearch docker-compose:

elasticsearch:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
        hostname: elasticsearch
        environment:
            - cluster.name=docker-cluster
            - discovery.type=single-node
            - network.host=0.0.0.0
            - xpack.security.enabled=true
            - xpack.security.transport.ssl.enabled=true
            - xpack.security.transport.ssl.key=certs/key.pem
            - xpack.security.transport.ssl.certificate=certs/cert.pem
            - xpack.security.http.ssl.enabled=true
            - xpack.security.http.ssl.key=certs/key.pem
            - xpack.security.http.ssl.certificate=certs/cert.pem
            - "ELASTIC_PASSWORD=${ELASTICSEARCH_PASSWORD}"
            - "ES_JAVA_OPTS=${ELASTICSEARCH_JAVA_OPTS}"
        volumes:
            - elasticsearch-data:/usr/share/elasticsearch/data
            - "${ELASTICSEARCH_HOST_VOLUME_CERTS}:/usr/share/elasticsearch/config/certs"
        ports:
            - 9200:9200
            - 9300:9300
        networks:
            - ${DOCKER_NETWORK_NAME}

kibana docker-compose:

kibana:
        image: docker.elastic.co/kibana/kibana:7.6.0
        hostname: elasticsearch
        environment:
            - SERVER_NAME=kibana.${DOMAIN}
            - SERVER_PORT=5601
            - SERVER_HOST=0.0.0.0
            - ELASTICSEARCH_HOSTS=https://elasticsearch:9200
            - SERVER_SSL_ENABLED=true
            - SERVER_SSL_CERTIFICATE=/usr/share/kibana/config/certs/cert.pem
            - SERVER_SSL_KEY=/usr/share/kibana/config/certs/key.pem
            - ELASTICSEARCH_USERNAME=elastic
            - ELASTICSEARCH_PASSWORD=${ELASTICSEARCH_PASSWORD}
            - XPACK_MONITORING_UI_CONTAINER_ELASTICSEARCH_ENABLED=true
        ports:
            - 5601:5601
        volumes:
            - "${KIBANA_HOST_VOLUME_CERTS}:/usr/share/kibana/config/certs"
        networks:
            - ${DOCKER_NETWORK_NAME}

Changing the hostname to kibana in the kibana container solved the curl issue.

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