# Failed to authenticate with host "https://elastic:9200": Hostname/IP does not match certificat

**URL:** <https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167>\
**Category:** Kibana\
**Tags:** elastic-stack-security\
**Created:** [June 25, 2022, 4:34pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167 "2022-06-25T16:34:15Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [June 25, 2022, 4:34pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/1 "2022-06-25T16:34:15Z")

</div>

Hello I was running Elastic on a pod in rancher kubernetes and Kibana in another one  
version 8.2.3  
So I ended up in this

 ![Screenshot from 2022-06-25 17-19-30](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bdad057de776717810337ab506e0ff6f5d1583e5.png)

with this log

```auto
[2022-06-25T16:15:56.848+00:00][ERROR][plugins.interactiveSetup.elasticsearch] Failed to authenticate with host "https://elastic:9200": Hostname/IP does not match certificate's altnames: Host: elastic. is not in the cert's altnames: DNS:elastic-759448c5cd-q5h5r, DNS:localhost, IP Address:127.0.0.1, IP Address:10.42.1.17

```

and for the elastic output I have to open it by this command only

```auto
curl -k -X GET https://elastic:9200 -u elastic

```

![Screenshot from 2022-06-25 17-25-52](https://us1.discourse-cdn.com/elastic/original/3X/9/7/970c5b834538650540502fbdc1c8f6be7026f8b1.png)

and I cant configure anything manually in the container I can't use Vim or Nano it doesn't exist in the container  
please please who could help me ?

```auto
[2022-06-25T16:15:56.848+00:00][ERROR][plugins.interactiveSetup.elasticsearch] Failed to authenticate with host "https://elastic:9200": Hostname/IP does not match certificate's altnames: Host: elastic. is not in the cert's altnames: DNS:elastic-759448c5cd-q5h5r, DNS:localhost, IP Address:127.0.0.1, IP Address:10.42.1.17

```

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [June 27, 2022, 10:37am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/2 "2022-06-27T10:37:11Z")

</div>

need solution

---

<div class="post-metadata">

**Author:** ![JLeysens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jleysens/32/67404_2.png) [@JLeysens](https://discuss.elastic.co/u/JLeysens)\
**Post date:** [June 27, 2022, 1:25pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/3 "2022-06-27T13:25:39Z")

</div>

Hello @medch1 ! Have a look at this issue and the solution:

> [@Host name does not match the certificate](https://discuss.elastic.co/t/host-name-does-not-match-the-certificate/269242):
>
> Hi, I am facing Host name does not match the certificate issue in ES. I tried checking in ES forum and some has asked to disable the CN name check at code level but in the same thread we also see that its not recommended solution. I have pasted the error below, Please help if you have found any other solution otherthan disabling the hostname verification at code level. I have 2 nodes in a cluster in Elastic Search and connecting from JBoss 7.1. Please find the url for which I referred, Error…

I believe you need to set the hostnames when generating the certificate by

> ...[setting] the appropriate hostname. See the `--dns` option to [certutil](https://www.elastic.co/guide/en/elasticsearch/reference/current/certutil.html)

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [June 27, 2022, 2:27pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/4 "2022-06-27T14:27:49Z")

</div>

Hello @JLeysens the solution isn't clear can you simplified it to me ?

---

<div class="post-metadata">

**Author:** ![JLeysens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jleysens/32/67404_2.png) [@JLeysens](https://discuss.elastic.co/u/JLeysens)\
**Post date:** [June 27, 2022, 2:42pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/5 "2022-06-27T14:42:18Z")

</div>

The error says that your domain name does not match what is in the certificate's domain name(s) certificate. I'm assuming your certificate was generated using `elasticsearch-certutil`? However it was generated it needs to be valid for the domain name "elastic" which it currently is not.

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [June 27, 2022, 11:36pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/6 "2022-06-27T23:36:35Z")

</div>

No no i'm sure it's correct do you need any screenshots

---

<div class="post-metadata">

**Author:** ![JLeysens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jleysens/32/67404_2.png) [@JLeysens](https://discuss.elastic.co/u/JLeysens)\
**Post date:** [June 28, 2022, 11:00am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/7 "2022-06-28T11:00:48Z")

</div>

You are running that curl command in insecure mode: `-k`. What do you see in the terminal without it?

Would you mind sharing `kibana.yml` and `elasticsearch.yml` config for hosts and network?

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [June 29, 2022, 9:55am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/8 "2022-06-29T09:55:25Z")

</div>

Hello again @JLeysens  
this is the _elasticsearch.yml_ file

 ![Screenshot from 2022-06-29 10-50-35](https://us1.discourse-cdn.com/elastic/original/3X/0/3/032cd70a50c0bf5e8a3e6d3dfc34fbb1a99b17fe.png)

and this is the _kibana_.yml file.

 ![Screenshot from 2022-06-29 10-51-52](https://us1.discourse-cdn.com/elastic/original/3X/c/0/c0fb787ea36c4b6c0cffaaefec2bfeb11a899317.png)

and I can't edit it, bash doesn't have neither vim or nano

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [July 13, 2022, 3:22pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/9 "2022-07-13T15:22:09Z")

</div>

up up up

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [July 14, 2022, 4:21am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/10 "2022-07-14T04:21:31Z")

</div>

The problem is that when your Elasticsearch node started, it thought it has the name `elastic-759448c5cd-q5h5r` and so it generated a certificate for that hostname.  
It didn't not include the hostname `elastic` in that certificate.

Now when you try to enroll Kibana to Elasticsearch, Elasticsearch is advertising that it has the address `elastic:9200`. Kibana tries to enroll on that address but the certificate doesn't match the hostname.

Did you change something during your setup that would cause Elasticsearch to think it now has a different hostname (`elastic` vs `elastic-759448c5cd-q5h5r`)?

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [July 14, 2022, 8:19am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/11 "2022-07-14T08:19:56Z")

</div>

No i didn't anything on my own , I did everything following the official documentation

---

<div class="post-metadata">

**Author:** ![prasannjeet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prasannjeet/32/108329_2.png) [@prasannjeet](https://discuss.elastic.co/u/prasannjeet)\
**Post date:** [July 14, 2022, 10:42pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/12 "2022-07-14T22:42:46Z")

</div>

Facing the exact same problem. Would be great there is a solution.

---

<div class="post-metadata">

**Author:** ![prasannjeet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prasannjeet/32/108329_2.png) [@prasannjeet](https://discuss.elastic.co/u/prasannjeet)\
**Post date:** [July 14, 2022, 11:35pm UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/13 "2022-07-14T23:35:37Z")

</div>

I was running kibana and es in docker. I solved my problem by creating a new network for es and kibana. First I ran the command:

```auto
docker network create elastic

```

This created a new docker network. Then I simply first ran Elasticsearch by the following docker-compose file:

```auto
version: '3.3'
services:
    elasticsearch:
        image: 'docker.elastic.co/elasticsearch/elasticsearch:8.3.2'
        container_name: es
        network_mode: elastic
        volumes:
            - '$PWD/esdata:/usr/share/elasticsearch/data'
        ports:
            - '9200:9200'
            - '9300:9300'
        environment:
            - logger.level=INFO

```

Followed by running kibana using the following docker compose file:

```auto
version: '3.3'
services:
    kibana:
        image: 'kibana:8.3.2'
        container_name: kibana
        network_mode: elastic
        ports:
            - '5601:5601'

```

The only thing to note here is the following line in the docker-compose file:

```auto
network_mode: elastic

```

And then when I configured kibana, there was no error! Hope that helps.

---

<div class="post-metadata">

**Author:** ![medch1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medch1/32/107576_2.png) [@medch1](https://discuss.elastic.co/u/medch1)\
**Post date:** [August 8, 2022, 8:58am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/14 "2022-08-08T08:58:55Z")

</div>

Thanks but it doesn't work on rancher , maybe your solution works for docker

---

<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:** [September 5, 2022, 8:59am UTC](https://discuss.elastic.co/t/failed-to-authenticate-with-host-https-elastic-9200-hostname-ip-does-not-match-certificat/308167/15 "2022-09-05T08:59:27Z")

</div>

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