# Python: ES.cluster.health() returns a Failed to establish a new connection: \[Errno 11001\] getaddrinfo failed) everytime I run

**URL:** <https://discuss.elastic.co/t/python-es-cluster-health-returns-a-failed-to-establish-a-new-connection-errno-11001-getaddrinfo-failed-everytime-i-run/211850>\
**Category:** Elasticsearch\
**Created:** [December 13, 2019, 9:49pm UTC](https://discuss.elastic.co/t/python-es-cluster-health-returns-a-failed-to-establish-a-new-connection-errno-11001-getaddrinfo-failed-everytime-i-run/211850 "2019-12-13T21:49:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Spedding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_spedding/32/46958_2.png) [@Paul\_Spedding](https://discuss.elastic.co/u/Paul_Spedding)\
**Post date:** [December 13, 2019, 9:49pm UTC](https://discuss.elastic.co/t/python-es-cluster-health-returns-a-failed-to-establish-a-new-connection-errno-11001-getaddrinfo-failed-everytime-i-run/211850/1 "2019-12-13T21:49:34Z")

</div>

So I have the following code:

self.es.cluster.health(wait\_for\_status='yellow', request\_timeout=1)

It was running originally but for some reason it stoped and I can't work out why, but no matter if I restart the server I will always get the following error.

{ConnectionError}ConnectionError(\<urllib3.connection.HTTPConnection object at 0x00000203122196A0\>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed) caused by: NewConnectionError(\<urllib3.connection.HTTPConnection object at 0x00000203122196A0\>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed)

Here is what ES is saying:

[2019-12-13T00:46:21,572][INFO][o.e.l.LicenseService] [DESKTOP-1N1BV30] license [5b61fe00-df18-4550-835d-24705d536ea9] mode [basic] - valid  
[2019-12-13T00:46:21,574][INFO][o.e.x.s.s.SecurityStatusChangeListener] [DESKTOP-1N1BV30] Active license is now [BASIC]; Security is disabled  
[2019-12-13T00:46:21,592][INFO][o.e.g.GatewayService] [DESKTOP-1N1BV30] recovered [2] indices into cluster\_state  
[2019-12-13T00:46:21,716][INFO][o.e.h.AbstractHttpServerTransport] [DESKTOP-1N1BV30] publish\_address {127.0.0.1:9200}, bound\_addresses {127.0.0.1:9200}, {[::1]:9200}  
[2019-12-13T00:46:21,723][INFO][o.e.n.Node] [DESKTOP-1N1BV30] started  
[2019-12-13T00:46:22,031][INFO][o.e.c.r.a.AllocationService] [DESKTOP-1N1BV30] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[forex][0]]]).

Why is this?

Thank you,

Merry Christmas.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 16, 2019, 8:56am UTC](https://discuss.elastic.co/t/python-es-cluster-health-returns-a-failed-to-establish-a-new-connection-errno-11001-getaddrinfo-failed-everytime-i-run/211850/2 "2019-12-16T08:56:55Z")

</div>

it looks as if Elasticsearch has started up just fine.

You python client's error message indicates that there is an issue with resolving the host that you used in order to connect to elasticsearch. Can you share your setup? Also, it looks as if you are running Elasticsearch on localhost only. So if the python client and Elasticsearch are not running on the same system, you need to

1. Bind Elasticsearch to an external IP address
2. Try to use the ip address of the elasticsearch node to see if the connection gets established and if that works figure out why there might be DNS issue.

Hope this helps!

--Alex

---

<div class="post-metadata">

**Author:** ![Paul\_Spedding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_spedding/32/46958_2.png) [@Paul\_Spedding](https://discuss.elastic.co/u/Paul_Spedding)\
**Post date:** [December 30, 2019, 4:36am UTC](https://discuss.elastic.co/t/python-es-cluster-health-returns-a-failed-to-establish-a-new-connection-errno-11001-getaddrinfo-failed-everytime-i-run/211850/3 "2019-12-30T04:36:42Z")

</div>

I manedge to fix it in the end. I was getting confused with the index naming. After I changed the names around it worked. Thanks for the help Alex 🙂

---

<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:** [January 27, 2020, 4:36am UTC](https://discuss.elastic.co/t/python-es-cluster-health-returns-a-failed-to-establish-a-new-connection-errno-11001-getaddrinfo-failed-everytime-i-run/211850/4 "2020-01-27T04:36:44Z")

</div>

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