# Can't get python client wait\_for\_status to work

**URL:** <https://discuss.elastic.co/t/cant-get-python-client-wait-for-status-to-work/123163>\
**Category:** Elasticsearch\
**Created:** [March 8, 2018, 11:57pm UTC](https://discuss.elastic.co/t/cant-get-python-client-wait-for-status-to-work/123163 "2018-03-08T23:57:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![melissachang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/melissachang/32/36684_2.png) [@melissachang](https://discuss.elastic.co/u/melissachang)\
**Post date:** [March 8, 2018, 11:57pm UTC](https://discuss.elastic.co/t/cant-get-python-client-wait-for-status-to-work/123163/1 "2018-03-08T23:57:11Z")

</div>

I'm using docker-compose to run two services: elasticsearch and a Python indexer. This works:

es = Elasticsearch([elasticsearch\_url])  
time.sleep(30)  
es.indices.delete(index=index\_name)

I'm trying to use wait\_for\_status instead of sleep:

es = Elasticsearch([elasticsearch\_url])  
es.cluster.health(wait\_for\_status='yellow', request\_timeout=30)  
es.indices.delete(index=index\_name)

I get (see [https://justpaste.it/1i16l](https://justpaste.it/1i16l)):

indexer\_1 | Traceback (most recent call last):  
indexer\_1 | File "indexer.py", line 142, in   
indexer\_1 | main()  
indexer\_1 | File "indexer.py", line 127, in main  
indexer\_1 | es = init\_elasticsearch(args.elasticsearch\_url, index\_name)  
indexer\_1 | File "indexer.py", line 61, in init\_elasticsearch  
indexer\_1 | es.cluster.health(wait\_for\_status='yellow', request\_timeout=30)  
indexer\_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 76, in \_wrapped  
indexer\_1 | return func(\*args, params=params, \*\*kwargs)  
indexer\_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/cluster.py", line 33, in health  
indexer\_1 | 'health', index), params=params)  
indexer\_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 314, in perform\_request  
indexer\_1 | status, headers\_response, data = connection.perform\_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)  
indexer\_1 | File "/usr/local/lib/python2.7/site-packages/elasticsearch/connection/http\_urllib3.py", line 158, in perform\_request  
indexer\_1 | raise ConnectionError('N/A', str(e), e)  
indexer\_1 | elasticsearch.exceptions.ConnectionError: ConnectionError(\<urllib3.connection.HTTPConnection object at 0x7f687e347450\>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(\<urllib3.connection.HTTPConnection object at 0x7f687e347450\>: Failed to establish a new connection: [Errno 111] Connection refused)  
bigquery\_indexer\_1 exited with code 1

I also tried:

es.cluster.health(wait\_for\_status='yellow')  
es.cluster.health(wait\_for\_status='yellow', timeout=30)

---

<div class="post-metadata">

**Author:** ![melissachang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/melissachang/32/36684_2.png) [@melissachang](https://discuss.elastic.co/u/melissachang)\
**Post date:** [March 28, 2018, 8:47pm UTC](https://discuss.elastic.co/t/cant-get-python-client-wait-for-status-to-work/123163/2 "2018-03-28T20:47:29Z")

</div>

Ping. (Don't want this to auto-close in a month).

---

<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 25, 2018, 8:47pm UTC](https://discuss.elastic.co/t/cant-get-python-client-wait-for-status-to-work/123163/3 "2018-04-25T20:47:30Z")

</div>

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