# \[Metricbeat 7.9\] x509: certificate is valid for instance, not localhost

**URL:** https://discuss.elastic.co/t/metricbeat-7-9-x509-certificate-is-valid-for-instance-not-localhost/266849
**Category:** Beats
**Tags:** metricbeat
**Created:** [March 10, 2021, 5:41pm UTC](https://discuss.elastic.co/t/metricbeat-7-9-x509-certificate-is-valid-for-instance-not-localhost/266849 "2021-03-10T17:41:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![glitz](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@glitz](https://discuss.elastic.co/u/glitz)
#### Post date: [March 10, 2021, 5:41pm UTC](https://discuss.elastic.co/t/metricbeat-7-9-x509-certificate-is-valid-for-instance-not-localhost/266849/1 "2021-03-10T17:41:32Z")

</div>

Hello,

I'm trying to send data from Metricbeat 7.9 to an already-tls-working Elasticsearch 7.9 but without success...It is a test environment, everything on same server(Elasticsearch, Kibana and Metricbeat)

my metricbeat.yml is:

```auto
> output.elasticsearch:
> # Array of hosts to connect to.
> hosts: ["localhost:9200"]
> 
> # Protocol - either `http` (default) or `https`.
> protocol: "https"
> 
> # Authentication credentials - either API key or username/password.
> #api_key: "id:api_key"
> username: "my_user"
> password: "my_pass"

```

After restart metricbeat daemon it starts but shows this message:

```auto
Failed to connect to backoff(elasticsearch(https://localhost:9200)): Get "https://localhost:9200": x509: certificate is valid for instance, not localhost

```

EDIT: as far as I understand ssl options for certificate and key are for authentication (as alternative to user/pass) maybe here is my confussion/mistake?

any tips?  
thanks

---

<div class="post-metadata">

### Author: ![glitz](https://avatars.discourse-cdn.com/v4/letter/g/f04885/32.png) [@glitz](https://discuss.elastic.co/u/glitz)
#### Post date: [March 16, 2021, 8:00pm UTC](https://discuss.elastic.co/t/metricbeat-7-9-x509-certificate-is-valid-for-instance-not-localhost/266849/2 "2021-03-16T20:00:27Z")

</div>

Solved

"instance" was a default name for canonical name inside certificate, so instead:

> bin/elasticsearch-certutil cert --ca myCA.p12

you should create certificate with:

> bin/elasticsearch-certutil cert --ca myCA.p12 --name myNode.p12

I'm not sure if this is the proper way but worked.

---

<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: [April 13, 2021, 10:01pm UTC](https://discuss.elastic.co/t/metricbeat-7-9-x509-certificate-is-valid-for-instance-not-localhost/266849/3 "2021-04-13T22:01:24Z")

</div>

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