# Elasticsearch connection idle timeout

**URL:** <https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283>\
**Category:** Elasticsearch\
**Created:** [October 15, 2020, 11:41pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283 "2020-10-15T23:41:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![lnitin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lnitin/32/63896_2.png) [@lnitin](https://discuss.elastic.co/u/lnitin)\
**Post date:** [October 15, 2020, 11:41pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/1 "2020-10-15T23:41:04Z")

</div>

Hello,  
Elasticsearch server is rejecting any communication after certain amount of time interval if there is no activity from source server and connection is getting lost.? Can connection be open at all times, Is there any timeout setting available to avoid 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:** [October 16, 2020, 2:32am UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/2 "2020-10-16T02:32:13Z")

</div>

Do you have a reverse proxy or a firewall or anything like that between the client and elasticsearch nodes?

---

<div class="post-metadata">

**Author:** ![lnitin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lnitin/32/63896_2.png) [@lnitin](https://discuss.elastic.co/u/lnitin)\
**Post date:** [October 16, 2020, 2:14pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/3 "2020-10-16T14:14:16Z")

</div>

Yeah we have a firewall between Client and Elasticsearch nodes, which is open and connection is working, but we have this issue intermittently when there is no activity for sometime. Elasticsearch is closing all client connections and causing timeouts at the client end for any other query after timeout.

---

<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:** [October 16, 2020, 4:31pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/4 "2020-10-16T16:31:50Z")

</div>

I think you have to configure your proxy/firewall for this. I'm pretty sure people also had issues in the past with their firewall. Did you google a bit or search on this site?

---

<div class="post-metadata">

**Author:** ![lnitin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lnitin/32/63896_2.png) [@lnitin](https://discuss.elastic.co/u/lnitin)\
**Post date:** [October 16, 2020, 4:38pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/5 "2020-10-16T16:38:51Z")

</div>

I checked with our network team they said once the connection is successful there is nothing wrong with network, most of the google suggestions are conflicting. Some of them says its something to do with elasticsearch, and some are like to increase the timeout at java elastic client. What's more strange is we are having this issue only on higher environments.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 16, 2020, 6:05pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/6 "2020-10-16T18:05:28Z")

</div>

Elasticsearch does not have an idle connection timeout (by default anyway) - it will let HTTP connections sit idle indefinitely. However, firewalls almost always _do_ time out idle connections, and is likely the cause of your problems. That's not to say there's anything "wrong" with the network if so, it's behaving as configured, but the configuration is not what Elasticsearch needs.

Elasticsearch also sends TCP keepalives on incoming HTTP connections to try and prevent them from being closed in this way. This doesn't always work, particularly if the firewall is configured to close connections before the first keepalive is sent. If that's what is happening, you need to adjust either your firewall or your keepalive config.

---

<div class="post-metadata">

**Author:** ![lnitin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lnitin/32/63896_2.png) [@lnitin](https://discuss.elastic.co/u/lnitin)\
**Post date:** [October 16, 2020, 6:37pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/7 "2020-10-16T18:37:26Z")

</div>

Thanks.. keepalive config is it an elasticsearch configuration setting.?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 16, 2020, 6:44pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/8 "2020-10-16T18:44:58Z")

</div>

No, it's a sysctl.

---

<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:** [November 13, 2020, 6:45pm UTC](https://discuss.elastic.co/t/elasticsearch-connection-idle-timeout/252283/9 "2020-11-13T18:45:04Z")

</div>

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