# Metricbeat in Kubernetes fails to find Elasticsearch host

**URL:** https://discuss.elastic.co/t/metricbeat-in-kubernetes-fails-to-find-elasticsearch-host/124867
**Category:** Beats
**Tags:** metricbeat
**Created:** [March 20, 2018, 9:05pm UTC](https://discuss.elastic.co/t/metricbeat-in-kubernetes-fails-to-find-elasticsearch-host/124867 "2018-03-20T21:05:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bladerunner512](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bladerunner512](https://discuss.elastic.co/u/bladerunner512)
#### Post date: [March 20, 2018, 9:05pm UTC](https://discuss.elastic.co/t/metricbeat-in-kubernetes-fails-to-find-elasticsearch-host/124867/1 "2018-03-20T21:05:36Z")

</div>

metricbeat 6.2.3/elasticsearch 6.2.2/kubernetes 1.9  
error:  
ERROR pipeline/output.go:74 Failed to connect: Get [http://elasticsearch:9200](http://elasticsearch:9200): lookup elasticsearch on 148.93.51.11:53: no such host

config values:  
ELASTICSEARCH\_HOST=elasticsearch  
ELASTICSEARCH\_PORT=9200

Where does '148.93.51.11:53' come from? No such IP in system?  
Works fine if host is changed to Kubernetes internal Cluster IP created for Elasticsearch service.

Interestingly, Filebeat has a similar config, but is able to resolve elasticsearch:9200 host

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [March 21, 2018, 3:55pm UTC](https://discuss.elastic.co/t/metricbeat-in-kubernetes-fails-to-find-elasticsearch-host/124867/2 "2018-03-21T15:55:18Z")

</div>

Hi @bladedrunner512,

That IP is the DNS server, the error comes from its answer.

In order to debug why Metricbeat cannot resolve `elasticsearch` we would need some more info about your deploy, like Metricbeat manifests and how elasticsearch is deployed. I understand there is an elasticsearch service in the same namespace?

Best regards

---

<div class="post-metadata">

### Author: ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)
#### Post date: [March 21, 2018, 3:58pm UTC](https://discuss.elastic.co/t/metricbeat-in-kubernetes-fails-to-find-elasticsearch-host/124867/3 "2018-03-21T15:58:55Z")

</div>

On a second though, I'm guessing this is related to `hostNetwork: true`. Have a look to [https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods-dns-policy](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pods-dns-policy). You can probably add `dnsPolicy: ClusterFirstWithHostNet` to fix this issue.

Please let me know if that fixes the issue, we may want to put that in the official manifest.

Best regards

---

<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 18, 2018, 3:58pm UTC](https://discuss.elastic.co/t/metricbeat-in-kubernetes-fails-to-find-elasticsearch-host/124867/4 "2018-04-18T15:58:57Z")

</div>

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