# Metricbeat fails to connect to elastisearch and ignores fields in yaml

**URL:** <https://discuss.elastic.co/t/metricbeat-fails-to-connect-to-elastisearch-and-ignores-fields-in-yaml/233409>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [May 19, 2020, 8:51pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-connect-to-elastisearch-and-ignores-fields-in-yaml/233409 "2020-05-19T20:51:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![syost](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@syost](https://discuss.elastic.co/u/syost)\
**Post date:** [May 19, 2020, 8:51pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-connect-to-elastisearch-and-ignores-fields-in-yaml/233409/1 "2020-05-19T20:51:35Z")

</div>

**ENVIRONMENT:**  
Amazon EC2 Instance  
ELK has been installed  
XPACK has been enabled  
Passwords have been set for built-in users  
metricbeat has been untar'd

**ISSUE:**  
When I start metricbeat it gives the following output indicating it can't connect...

```auto
2020-05-19T20:39:59.505Z	ERROR	[publisher_pipeline_output]	pipeline/output.go:106	Failed to connect to backoff(elasticsearch(http://localhost:9200)): Get http://localhost:9200: dial tcp 127.0.0.1:9200: connect: connection refused
2020-05-19T20:39:59.505Z	INFO	[publisher_pipeline_output]	pipeline/output.go:99	Attempting to reconnect to backoff(elasticsearch(http://localhost:9200)) with 8 reconnect attempt(s)
2020-05-19T20:39:59.505Z	INFO	[publisher]	pipeline/retry.go:196	retryer: send unwait-signal to consumer
2020-05-19T20:39:59.505Z	INFO	[publisher]	pipeline/retry.go:198 done
2020-05-19T20:39:59.506Z	INFO	[publisher]	pipeline/retry.go:173	retryer: send wait signal to consumer
2020-05-19T20:39:59.506Z	INFO	[publisher]	pipeline/retry.go:175 done
2020-05-19T20:40:12.086Z	INFO	[monitoring]	log/log.go:145	Non-zero metrics in the last 30s	{"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":1310,"time":{"ms":223}},"total":{"ticks":2370,"time":{"ms":392},"value":2370},"user":{"ticks":1060,"time":{"ms":169}}},"handles":{"limit":{"hard":4096,"soft":1024},"open":10},"info":{"ephemeral_id":"b248a7f0-212a-4b41-90d2-5697735d4150","uptime":{"ms":180094}},"memstats":{"gc_next":30397152,"memory_alloc":23091744,"memory_total":325630568,"rss":3928064},"runtime":{"goroutines":65}},"libbeat":{"config":{"module":{"running":0}},"pipeline":{"clients":10,"events":{"active":313,"published":51,"retry":17,"total":51}}},"metricbeat":{"system":{"cpu":{"events":3,"success":3},"load":{"events":3,"success":3},"memory":{"events":3,"success":3},"network":{"events":15,"success":15},"process":{"events":21,"success":21},"process_summary":{"events":3,"success":3},"socket_summary":{"events":3,"success":3}}},"system":{"load":{"1":0,"15":0.05,"5":0.01,"norm":{"1":0,"15":0.025,"5":0.005}}}}}}

```

It's saying that it failed to connect to `localhost:9200` but in my **metricbeat.yml** file I specifically told it that elasticsearch is `172.32.56.218:9200` as well as where Kibana is as indicated below...

```auto
metricbeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 1
  index.codec: best_compression
setup.dashboards.enabled: true
setup.kibana:
  host: "172.32.56.218.5601"
output.elasticsearch:
  hosts: ["172.32.56.218.9200"]
processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

```

_NOTE:_  
_I have setup built-in passwords for the built-in users only. That's all the security i've setup at this time._

Therefore, I'm confused why it's failing to connect and why it says localhost when I've already told it in the metricbeat yaml that it's not local host.

---

<div class="post-metadata">

**Author:** ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)\
**Post date:** [May 19, 2020, 11:43pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-connect-to-elastisearch-and-ignores-fields-in-yaml/233409/2 "2020-05-19T23:43:54Z")

</div>

Hello! What's the command you use to start metricbeat?

---

<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:** [June 16, 2020, 11:44pm UTC](https://discuss.elastic.co/t/metricbeat-fails-to-connect-to-elastisearch-and-ignores-fields-in-yaml/233409/3 "2020-06-16T23:44:02Z")

</div>

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