# Stop elasticsearch\_dsl from sending events to Elastic when server is down

**URL:** <https://discuss.elastic.co/t/stop-elasticsearch-dsl-from-sending-events-to-elastic-when-server-is-down/310977>\
**Category:** Elasticsearch\
**Tags:** docker, elastic-agent\
**Created:** [July 29, 2022, 10:36am UTC](https://discuss.elastic.co/t/stop-elasticsearch-dsl-from-sending-events-to-elastic-when-server-is-down/310977 "2022-07-29T10:36:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adso\_4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adso_4/32/99542_2.png) [@Adso\_4](https://discuss.elastic.co/u/Adso_4)\
**Post date:** [July 29, 2022, 10:36am UTC](https://discuss.elastic.co/t/stop-elasticsearch-dsl-from-sending-events-to-elastic-when-server-is-down/310977/1 "2022-07-29T10:36:07Z")

</div>

We have a django web application that sends user data with elasticsearch\_dsl library to an APM server. Our Elastic Stack is mounted with docker-compose, with Kibana, Elasticsearch and APM nodes.

For every user interaction, django tracking analyzer creates the corresponding instance in our database, and signals elasticsearch\_dsl to synchronize data with APM server.

What we have experienced is that, in the case of APM server down, the server cannot respond and the nginx timeout is triggered:

`upstream prematurely closed connection while reading response header from upstream`

Is there a way to avoid sending elasticsearch\_dsl signals when the server is down? How can we detect the server availability to avoid sending this request to APM?

---

<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:** [August 26, 2022, 10:36am UTC](https://discuss.elastic.co/t/stop-elasticsearch-dsl-from-sending-events-to-elastic-when-server-is-down/310977/2 "2022-08-26T10:36:15Z")

</div>

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