# Read timeout error after setting the request\_timeout

**URL:** <https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626>\
**Category:** Elasticsearch\
**Created:** [April 19, 2018, 5:18am UTC](https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626 "2018-04-19T05:18:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [April 19, 2018, 5:18am UTC](https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626/1 "2018-04-19T05:18:10Z")

</div>

Hi ,

I am feteching the data via python script and getting the following error:

elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=30))

I am using the following command to set the connection

res = es.search(index='event\*', doc\_type='farm',size=5000,  
body={"sort": [{"@timestamp": {"order": "asc"}}],"query": {"match": {"id": id}}},request\_timeout=30)

---

<div class="post-metadata">

**Author:** ![JKhondhu](https://avatars.discourse-cdn.com/v4/letter/j/ed655f/32.png) [@JKhondhu](https://discuss.elastic.co/u/JKhondhu)\
**Post date:** [April 19, 2018, 6:26pm UTC](https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626/2 "2018-04-19T18:26:36Z")

</div>

Is your elasticsearch cluster running on the same host and the python client?

I have noted that size param you are asking for but first, what do you see when you increase the timeout param from 30 to 60?

---

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [April 20, 2018, 3:08am UTC](https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626/3 "2018-04-20T03:08:29Z")

</div>

No elastic search cluster is running on different machine and I am running the script from a different machine.

One interesting thing I found it's getting timeout in first 2-3 attempt but after that it's working fine and I am getting the output.

You can see this . First time it failed due to time timeout , second time it was almost near to timeout and third time it resolved within 1-2 seconds. I have highlighted the start and end time of every execution for your reference.

[niraj@sj-niraj ~/ELK]$ date;./run.py --cluster sol 952552;date  
**_Thu Apr 19 19:10:38 PDT 2018_**

GET [http://hnode07:9200/lsbevent\*/farm-lsbevent/\_search?size=5000](http://hnode07:9200/lsbevent*/farm-lsbevent/_search?size=5000) [status:N/A request:60.012s]  
Traceback (most recent call last):  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 386, in \_make\_request  
six.raise\_from(e, None)  
File "", line 2, in raise\_from  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 382, in \_make\_request  
httplib\_response = conn.getresponse()  
File "/python/v3.6.1/lib/python3.6/http/client.py", line 1331, in getresponse  
response.begin()  
File "/python/v3.6.1/lib/python3.6/http/client.py", line 297, in begin  
version, status, reason = self.\_read\_status()  
File "/python/v3.6.1/lib/python3.6/http/client.py", line 258, in \_read\_status  
line = str(self.fp.readline(\_MAXLINE + 1), "iso-8859-1")  
File "/python/v3.6.1/lib/python3.6/socket.py", line 586, in readinto  
return self.\_sock.recv\_into(b)  
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/connection/http\_urllib3.py", line 147, in perform\_request  
response = self.pool.urlopen(method, url, body, retries=False, headers=self.headers, \*\*kw)  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 649, in urlopen  
\_stacktrace=sys.exc\_info()[2])  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/util/retry.py", line 333, in increment  
raise six.reraise(type(error), error, \_stacktrace)  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise  
raise value  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen  
chunked=chunked)  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 388, in \_make\_request  
self.\_raise\_timeout(err=e, url=url, timeout\_value=read\_timeout)  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 308, in \_raise\_timeout  
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout\_value)  
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/connection/http\_urllib3.py", line 147, in perform\_request  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 649, in urlopen  
\_stacktrace=sys.exc\_info()[2])  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/util/retry.py", line 333, in increment  
raise six.reraise(type(error), error, \_stacktrace)  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise  
raise value  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen  
chunked=chunked)  
File "/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 388, in \_make\_request  
self.\_raise\_timeout(err=e, url=url, timeout\_value=read\_timeout)  
File "s/python/v3.6.1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 308, in \_raise\_timeout  
raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout\_value)  
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File "./bhist", line 23, in   
res=elstic\_cluster\_connection.conn(jobid)  
File "/home/niraj/ELK/elstic\_cluster\_connection.py", line 24, in conn  
body={"sort": [{"@timestamp": {"order": "asc"}}],"query": {"match": {"jobid": jobid}}},request\_timeout=60)  
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/client/utils.py", line 76, in \_wrapped  
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/client/ **init**.py", line 636, in search  
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/transport.py", line 314, in perform\_request  
File "/python/v3.6.1/lib/python3.6/site-packages/elasticsearch-6.0.0-py3.6.egg/elasticsearch/connection/http\_urllib3.py", line 155, in perform\_request  
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='hnode07', port=9200): Read timed out. (read timeout=60))  
**_Thu Apr 19 19:11:39 PDT 2018_**

==============================================================================

[niraj@sj-niraj ~/ELK]$ date ; ./run.py --cluster sol 952552 ; date  
**_Thu Apr 19 19:11:53 PDT 2018_**

Job\<952552\>, Job Name \<\>, User   
Sun Mar 25 22:55:01 2018: Starting (Pid 10316);

Summary of time in seconds spent in various states

4506 0 126 0 0 0 4632

**_Thu Apr 19 19:12:06 PDT 2018_**  
[niraj@sj-niraj ~/ELK]$

=================================================================================  
[niraj@sj-niraj ~/ELK]$ date ; ./run.py --cluster sol 952552 ; date  
**_Thu Apr 19 19:15:36 PDT 2018_**

Job\<952552\>, Job Name \<\>, User   
Sun Mar 25 22:55:01 2018: Starting (Pid 10316);

Summary of time in seconds spent in various states

4506 0 126 0 0 0 4632

**_Thu Apr 19 19:15:37 PDT 2018_**

---

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [April 20, 2018, 3:09am UTC](https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626/4 "2018-04-20T03:09:38Z")

</div>

I increased the request\_timeout from 30 to 60 as well but the issue is same as said above

---

<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:** [May 18, 2018, 3:09am UTC](https://discuss.elastic.co/t/read-timeout-error-after-setting-the-request-timeout/128626/5 "2018-05-18T03:09:55Z")

</div>

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