# APM-Agent not connecting to APM-Server over HTTPS

**URL:** <https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756>\
**Category:** APM\
**Created:** [November 7, 2018, 4:11pm UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756 "2018-11-07T16:11:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheNmaptomyHeartBeat](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@TheNmaptomyHeartBeat](https://discuss.elastic.co/u/TheNmaptomyHeartBeat)\
**Post date:** [November 7, 2018, 4:11pm UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/1 "2018-11-07T16:11:34Z")

</div>

I have my Elasticsearch server and my APM-Server on in the same server.

My APM-Agent is installed on a separate server, where my application is.

The problem is that where the agent is installed the application enforces a strict HSTS policy. So when I try to send the metrics from the agent to my APM-Server on `http://1.2.3.4:8200` the request is cancelled, as it's sent over plain text rather than HTTPS protocol.

I attempted to install the APM-Server on the same server as as the APM-Agent. And tell it to connected to `http://localhost:8200`. But that also has connection issues and doesn't work.

I looked into setting up SSL on the APM-Server but unfortunately because it's an IP and doesn't have DNS Let's Encrypt's certificates doesn't work.

If anyone can suggest a solution i'd be very grateful. I'm not really sure what to do, or if i'm missing something obvious that stops this from being a problem.

Side note: I do think having agent send data over HTTPS is a better option. I'm not sure why localhost didn't work but that would also be good option I

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [November 7, 2018, 7:51pm UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/2 "2018-11-07T19:51:56Z")

</div>

If you can, [configure the APM Server](https://www.elastic.co/guide/en/apm/server/6.5/securing-apm-server.html#ssl-setup) with a self-signed SSL certificate.

After that you need to tell the APM agent not to validate the certificate using `ELASTIC_APM_VERIFY_SERVER_CERT=false`. Here's an example from the Node.js agent (but all the agents have this config option):

[https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#validate-server-cert](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#validate-server-cert)

Let me know if this solves your problem 🙂

---

<div class="post-metadata">

**Author:** ![TheNmaptomyHeartBeat](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@TheNmaptomyHeartBeat](https://discuss.elastic.co/u/TheNmaptomyHeartBeat)\
**Post date:** [November 8, 2018, 3:51pm UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/3 "2018-11-08T15:51:59Z")

</div>

Thank you for replying.  
I set up a self-signed certificate and added `verifyServerCert: 'false'`.

It worked to the point where it hit the APM-Server port.

then it gave me a `net::ERR_CERT_AUTHORITY_INVALID`.

I'm assuming it's the browser that's stopping that?

I tried `curl -k https://apm-server:8200` and that gives me a `404 page not found`.I read somewhere it means the server is working.

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [November 8, 2018, 7:31pm UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/4 "2018-11-08T19:31:46Z")

</div>

Ah, sorry if I misunderstood. Are you using the RUM agent? You're correct that the browser requires the https connection to be using a proper trusted certificate.

---

<div class="post-metadata">

**Author:** ![TheNmaptomyHeartBeat](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@TheNmaptomyHeartBeat](https://discuss.elastic.co/u/TheNmaptomyHeartBeat)\
**Post date:** [November 9, 2018, 9:43am UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/5 "2018-11-09T09:43:29Z")

</div>

I'm using the JS agent, and I have the RUM agent enabled in my apm-server configurations.

If thats the case I'm going to have to either get a certificate from an authority that allows the use of IP addresses or give my apm-server a DNS and use Let's Encrypt.

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [November 9, 2018, 10:15am UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/6 "2018-11-09T10:15:40Z")

</div>

What I'd normally recommend in a situation like this is to put a load balancer or similar proxy in front of the APM Server in which you terminate the SSL/TLS connection coming from the browser.

The communication from the proxy to the APM Server would then either happen over plain old HTTP or via a self signed certificate if you can configure your proxy to allow that.

Would that work in your scenario?

---

<div class="post-metadata">

**Author:** ![TheNmaptomyHeartBeat](https://avatars.discourse-cdn.com/v4/letter/t/47e85d/32.png) [@TheNmaptomyHeartBeat](https://discuss.elastic.co/u/TheNmaptomyHeartBeat)\
**Post date:** [November 9, 2018, 1:55pm UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/7 "2018-11-09T13:55:55Z")

</div>

Yes, that sounds as good of solution as any.

Thank for your help.

---

<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:** [November 30, 2018, 9:55am UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/8 "2018-11-30T09:55:56Z")

</div>

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

---

<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:** [November 30, 2018, 9:55am UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/9 "2018-11-30T09:55:57Z")

</div>



---

<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:** [November 4, 2022, 6:42am UTC](https://discuss.elastic.co/t/apm-agent-not-connecting-to-apm-server-over-https/155756/10 "2022-11-04T06:42:40Z")

</div>


