# Is Elasticsearch going to sleep after some hours?

**URL:** <https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035>\
**Category:** Elasticsearch\
**Created:** [May 4, 2021, 6:28am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035 "2021-05-04T06:28:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![JdKock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jdkock/32/26327_2.png) [@JdKock](https://discuss.elastic.co/u/JdKock)\
**Post date:** [May 4, 2021, 6:28am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/1 "2021-05-04T06:28:41Z")

</div>

We are using Elasticsearch (v7.3.2) for our search solution and we use a Java API to get the search results from Elasticsearch. This is working fine.

In the Test environment we are not using Elasticsearch everyday. What I've noticed now is that if I do a new call to Elasticsearch this request is failing the first time. The next calls are going ok and give results.  
It looks like Elasticsearch is going to "sleep mode" after a couple of hours not getting any requests. But I can't find anything about this in the documentation but I found another question here about the same issue.

> [@Does Elasticsearch go to sleep when there are no requests for a couple of hours?](https://discuss.elastic.co/t/does-elasticsearch-go-to-sleep-when-there-are-no-requests-for-a-couple-of-hours/231632):
>
> My development sever is a windows machine, and I leave Elasticsearch running at the end of the day... I have noticed that, every time I start working the next day, the first search request from Elasticsearch does not return any result... but if I make the same request a second time, then it would return some result. In fact I have added a logic to my code, to test Elasticsearch result, if it's empty, my code will wait for 500ms, and re-sends the same request. This will only happen when Elastics…

Strange enough there is no clear answer from Elasticsearch.

So my question, is there some kind of sleep mode for Elasticsearch after some time? Can I disable this ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 4, 2021, 6:52am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/2 "2021-05-04T06:52:24Z")

</div>

I think you are asking about the elasticsearch client and not the server.

I honestly don't know. I wonder if there are some keep alive settings for the underlying http client which can be configured within the low level client.

You can always use the sniffer at it sends every 5 minutes a request to the cluster and see if that changes the behavior. [Usage | Java REST Client [7.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_usage.html)

May be others have better ideas 😉

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 4, 2021, 7:07am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/3 "2021-05-04T07:07:12Z")

</div>

> [@JdKock](#):
>
> So my question, is there some kind of sleep mode for Elasticsearch after some time? Can I disable this ?

There is not, no.

---

<div class="post-metadata">

**Author:** ![JdKock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jdkock/32/26327_2.png) [@JdKock](https://discuss.elastic.co/u/JdKock)\
**Post date:** [May 4, 2021, 7:26am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/4 "2021-05-04T07:26:16Z")

</div>

@warkolm : How do you know? Did you tried it?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 4, 2021, 7:28am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/5 "2021-05-04T07:28:39Z")

</div>

I am pretty sure if we had that sort of functionality anywhere in the Elasticsearch code base, it'd be documented. That seems like a large enough gotcha to make it visible on multiple levels.

---

<div class="post-metadata">

**Author:** ![JdKock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jdkock/32/26327_2.png) [@JdKock](https://discuss.elastic.co/u/JdKock)\
**Post date:** [May 4, 2021, 7:29am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/6 "2021-05-04T07:29:48Z")

</div>

Ok, but than the qustion, how come my first calls fails after some hours? Nothing to do with Elasticsearch you think ?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 4, 2021, 7:30am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/7 "2021-05-04T07:30:35Z")

</div>

There is no sleep mode in Elasticsearch but the operating system can naturally manage processes so it may be at the OS level.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 4, 2021, 7:30am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/8 "2021-05-04T07:30:44Z")

</div>

I would strongly suggest it's what David mentioned, so check whatever client you are using and if it has a timeout.

---

<div class="post-metadata">

**Author:** ![JdKock](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jdkock/32/26327_2.png) [@JdKock](https://discuss.elastic.co/u/JdKock)\
**Post date:** [May 4, 2021, 7:59am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/9 "2021-05-04T07:59:10Z")

</div>

What I'm going to test is to do one call each day from Postman. Let's see how that goes.  
Then I'm not using our Java API. Just do a call directly to Elasticsearch.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 4, 2021, 8:20am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/10 "2021-05-04T08:20:34Z")

</div>

Do you have a Proxy in the middle by any chance?

---

<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 1, 2021, 8:20am UTC](https://discuss.elastic.co/t/is-elasticsearch-going-to-sleep-after-some-hours/272035/11 "2021-06-01T08:20:42Z")

</div>

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