# Upstream prematurely closed connection while reading response header from upstream - ES/kibana

**URL:** <https://discuss.elastic.co/t/upstream-prematurely-closed-connection-while-reading-response-header-from-upstream-es-kibana/26246>\
**Category:** Elasticsearch\
**Created:** [July 24, 2015, 1:57pm UTC](https://discuss.elastic.co/t/upstream-prematurely-closed-connection-while-reading-response-header-from-upstream-es-kibana/26246 "2015-07-24T13:57:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shome\_dnal](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@shome\_dnal](https://discuss.elastic.co/u/shome_dnal)\
**Post date:** [July 24, 2015, 1:57pm UTC](https://discuss.elastic.co/t/upstream-prematurely-closed-connection-while-reading-response-header-from-upstream-es-kibana/26246/1 "2015-07-24T13:57:19Z")

</div>

hello all

my setup is as such:

> nginx(\*:443) -\> kibana(127.0.0.1:5601) -\> elasticsearch (127.0.0.1:5106)

using kibana with elasticsearch for anything under 3 days timestamp is perfect and it runs smoothly; though if i seek back longer it gives me a gateway timeout...  
in nginx error log i see "upstream prematurely closed connection while reading response header from upstream"

> 1852#0: \*200 upstream prematurely closed connection while reading response header from upstream, client: X.X.X.X, server: kibana.interface.fake, request: "POST /elasticsearch/\_msearch?timeout=0&ignore\_unavailable=true&preference=1437744706387 HTTP/1.1", upstream: "[http://127.0.0.1:5601/elasticsearch/\_msearch?timeout=0&ignore\_unavailable=true&preference=1437744706387](http://127.0.0.1:5601/elasticsearch/_msearch?timeout=0&ignore_unavailable=true&preference=1437744706387)", host: "kibana.interface.fake", referrer: "[https://kibana.interface.fake/](https://kibana.interface.fake/)"

i don't have a problem in waiting for any time it takes to show me the output so i increased every proxy\_read and proxy\_send as well as header timeout i know of in nginx; and that is still causing a gateway timeout when query takes longer to execute...  
server has good specs though internet bandwidth on client side is a bit slow so it may take a while to retrieve all data and visualize them...

any advice on how to fix this ?

---

<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:** [July 25, 2015, 2:24am UTC](https://discuss.elastic.co/t/upstream-prematurely-closed-connection-while-reading-response-header-from-upstream-es-kibana/26246/2 "2015-07-25T02:24:25Z")

</div>

Maybe try increasing the timeout on nginx's side.

---

<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:** [July 5, 2017, 11:59pm UTC](https://discuss.elastic.co/t/upstream-prematurely-closed-connection-while-reading-response-header-from-upstream-es-kibana/26246/3 "2017-07-05T23:59:03Z")

</div>


