# Unable to connect 502 during a bulk document upload

**URL:** <https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [May 24, 2022, 3:57pm UTC](https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527 "2022-05-24T15:57:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukelindner01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukelindner01/32/105429_2.png) [@lukelindner01](https://discuss.elastic.co/u/lukelindner01)\
**Post date:** [May 24, 2022, 3:57pm UTC](https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527/1 "2022-05-24T15:57:02Z")

</div>

Heya. I'm new with Elastic Search and AppSearch but we have setup an engine and am attempting to bulk upload a 100 documents per request and up to 1000 requests, throttled to 10 at a time via a semaphore (c#). I keep on getting the below http exception shortly after initiating the bulk upload (the first couple succeed without issue):

```
An existing connection was forcibly closed by the remote host.

```

When I try and view my appsearch engine though, I see that it is unavailable

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/9/39d30ecebb2505f1406c9cc2dc89c63b706f5a3c.png)

After some time, it resolves itself, but becomes unavailable again if I reattempt the bulk uploads.

I am assuming my document uploads are crashing our instance/engine. How do I resolve this?

---

<div class="post-metadata">

**Author:** ![ross.bell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ross.bell/32/77559_2.png) [@ross.bell](https://discuss.elastic.co/u/ross.bell)\
**Post date:** [May 24, 2022, 4:12pm UTC](https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527/2 "2022-05-24T16:12:44Z")

</div>

Hey @lukelindner01,

You'll likely want to do one or both of:

- Reduce your concurrent indexing request count
- Increase Enterprise Search and Elasticsearch resource capacity (Elasticsearch matters more after a point)

I'd recommend, starting at _1_, increasing concurrent indexing request count to understand when indexing requests begin to affect performance. Then you can increase cluster capacity as needed to achieve your desired indexing throughput.

I hope that helps!

Ross

---

<div class="post-metadata">

**Author:** ![lukelindner01](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukelindner01/32/105429_2.png) [@lukelindner01](https://discuss.elastic.co/u/lukelindner01)\
**Post date:** [May 25, 2022, 10:05am UTC](https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527/3 "2022-05-25T10:05:16Z")

</div>

> [@ross.bell](#):
>
> concurrent indexing request

Thanks @ross.bell. When you mention the concurrent indexing request count, are you refering to the amount of concurrent document uploads we are attempting at a time?

---

<div class="post-metadata">

**Author:** ![ross.bell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ross.bell/32/77559_2.png) [@ross.bell](https://discuss.elastic.co/u/ross.bell)\
**Post date:** [May 25, 2022, 2:29pm UTC](https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527/4 "2022-05-25T14:29:00Z")

</div>

Yep, you mention you're issuing 10 requests in parallel. You'll want to play around with how many parallel requests your cluster size supports. It sounds like it's currently too small to handle 10.

---

<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 22, 2022, 2:29pm UTC](https://discuss.elastic.co/t/unable-to-connect-502-during-a-bulk-document-upload/305527/5 "2022-06-22T14:29:55Z")

</div>

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