# APM Can't connect to ElasticSearch

**URL:** <https://discuss.elastic.co/t/apm-cant-connect-to-elasticsearch/207578>\
**Category:** APM\
**Tags:** rum, server\
**Created:** [November 12, 2019, 7:39pm UTC](https://discuss.elastic.co/t/apm-cant-connect-to-elasticsearch/207578 "2019-11-12T19:39:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghaith\_Haddad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ghaith_haddad/32/49288_2.png) [@Ghaith\_Haddad](https://discuss.elastic.co/u/Ghaith_Haddad)\
**Post date:** [November 12, 2019, 7:39pm UTC](https://discuss.elastic.co/t/apm-cant-connect-to-elasticsearch/207578/1 "2019-11-12T19:39:45Z")

</div>

Hello everyone,

So i have a ELK setup on my EC2 Ubuntu 18.04 LTS server working perfectly fine. Now im trying to install APM but im having issues with the configuration. Everytime i try to start the apm service i keep getting connection to ElasticSearch refused because it keeps trying to connect to "localhost:9200" when its supposed to connect to :server-private-ip:9200".

Does anyone know why is that or how can i make apm connect to the correct ES ip and port?

Here is my ES setup starting from RUM:

```
rum:
    enabled: true

    allow_origins : ['*']
    library_pattern: "node_modules|bower_components|~"
    source_mapping:

      enabled: true

  elasticsearch:
    hosts: ["server-ip:9200"]
    index: "apm-%{[observer.version]}-%{+yyyy.MM.dd}"

```

I've removed all the comments to make it easier to read. Am i doing something wrong here? if so can someone please direct me into the right way?

Any help or guidance is greatly appreciated!

Cheers

---

<div class="post-metadata">

**Author:** ![gil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gil/32/41911_2.png) [@gil](https://discuss.elastic.co/u/gil)\
**Post date:** [November 12, 2019, 9:32pm UTC](https://discuss.elastic.co/t/apm-cant-connect-to-elasticsearch/207578/2 "2019-11-12T21:32:49Z")

</div>

Hi @Ghaith_Haddad. This looks like a yaml formatting issue, can you ensure `elasticsearch` is nested under `output`? Alternatively, you can combine things so the config reads:

```auto
output.elasticsearch:
    hosts: ["server-ip:9200"]
    index: "apm-%{[observer.version]}-%{+yyyy.MM.dd}"

```

`rum` is also a nested configuration, under `apm-server`. This should look like:

```auto
apm-server:
    rum:
        enabled: true

```

---

<div class="post-metadata">

**Author:** ![Ghaith\_Haddad](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ghaith_haddad/32/49288_2.png) [@Ghaith\_Haddad](https://discuss.elastic.co/u/Ghaith_Haddad)\
**Post date:** [November 12, 2019, 9:41pm UTC](https://discuss.elastic.co/t/apm-cant-connect-to-elasticsearch/207578/3 "2019-11-12T21:41:52Z")

</div>

that worked thank you very much!

---

<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:** [December 3, 2019, 5:41pm UTC](https://discuss.elastic.co/t/apm-cant-connect-to-elasticsearch/207578/4 "2019-12-03T17:41:57Z")

</div>

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