# Gateway Timeout on Update By Query API

**URL:** <https://discuss.elastic.co/t/gateway-timeout-on-update-by-query-api/83471>\
**Category:** Elasticsearch\
**Created:** [April 25, 2017, 12:03am UTC](https://discuss.elastic.co/t/gateway-timeout-on-update-by-query-api/83471 "2017-04-25T00:03:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![petar](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@petar](https://discuss.elastic.co/u/petar)\
**Post date:** [April 25, 2017, 12:03am UTC](https://discuss.elastic.co/t/gateway-timeout-on-update-by-query-api/83471/1 "2017-04-25T00:03:56Z")

</div>

Some of our update by query requests ([https://www.elastic.co/guide/en/elasticsearch/reference/2.4/docs-update-by-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/docs-update-by-query.html)) are timing out and returning a 504 Gateway Timeout error:

```auto
  status: 504,
  displayName: 'GatewayTimeout',
  message: 'Gateway Timeout' 

```

What we're trying to do is find certain products that match the query\_string and assign them a gender value.

Here's the query that is timing out:

```
POST /products/_update_by_query?conflicts=proceed
{
	"script": {
	    "id": "gender_women",
	    "lang": "groovy"
	},
	"query": {
	    "query_string": {
	        "query": "category:(skirts)"
	    }
	}
}

```

And the pre-defined script that changes the gender field on the product:

```
POST /_scripts/groovy/gender_women
{
     "script": "ctx._source.gender = \"women\""
}

```

I'm wondering what the cause of the Gateway Timeouts usually is and what we can do to make sure the queries are executed successfully.

Some background on our index, its an online product based index with about 250k documents.

We're running Elasticsearch 2.4.1 on a cluster with 8GB memory, hosted on Elastic Cloud. The index in question has 3 shards and 1 replica.

Thank You!

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [April 25, 2017, 12:20am UTC](https://discuss.elastic.co/t/gateway-timeout-on-update-by-query-api/83471/2 "2017-04-25T00:20:28Z")

</div>

A 504 error is frequently caused by having a Load Balancer in front of your Elasticsearch cluster. If the timeout on the Load Balancer is shorter than the duration of your update-by-query requests, it will result in a 504.

This can also happen with some proxy servers.

---

<div class="post-metadata">

**Author:** ![petar](https://avatars.discourse-cdn.com/v4/letter/p/dfb087/32.png) [@petar](https://discuss.elastic.co/u/petar)\
**Post date:** [April 25, 2017, 12:33am UTC](https://discuss.elastic.co/t/gateway-timeout-on-update-by-query-api/83471/3 "2017-04-25T00:33:59Z")

</div>

We're on the Elastic Cloud hosting service.

Unfortunately I don't see a configurable load balancer timeout on there.

---

<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:** [May 23, 2017, 12:42am UTC](https://discuss.elastic.co/t/gateway-timeout-on-update-by-query-api/83471/4 "2017-05-23T00:42:11Z")

</div>

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