# StatusCodeError: Request Timeout after 30000ms in Node JS

**URL:** <https://discuss.elastic.co/t/statuscodeerror-request-timeout-after-30000ms-in-node-js/256461>\
**Category:** Elasticsearch\
**Created:** [November 24, 2020, 8:15am UTC](https://discuss.elastic.co/t/statuscodeerror-request-timeout-after-30000ms-in-node-js/256461 "2020-11-24T08:15:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeussyed](https://avatars.discourse-cdn.com/v4/letter/z/c6cbf5/32.png) [@zeussyed](https://discuss.elastic.co/u/zeussyed)\
**Post date:** [November 24, 2020, 8:15am UTC](https://discuss.elastic.co/t/statuscodeerror-request-timeout-after-30000ms-in-node-js/256461/1 "2020-11-24T08:15:18Z")

</div>

I am using elasticSearch 16.7.1

I am doing a multisearch query from node js.  
In my local environment, I am able to get the results from the elastic server which is running on [http://elasticsearch.tpconnects.com:9200](http://elasticsearch.tpconnects.com:9200). But when from the aws server i cant get results because of the below error.

StatusCodeError: Request Timeout after 30000ms  
0|app | at /home/aggregator-backend/node\_modules/elasticsearch/src/lib/transport.js:397:9  
0|app | at Timeout. (/home/aggregator-backend/node\_modules/elasticsearch/src/lib/transport.js:429:7)  
0|app | at Timeout. (/home/aggregator-backend/node\_modules/async-listener/glue.js:188:31)  
0|app | at listOnTimeout (internal/timers.js:554:17)  
0|app | at processTimers (internal/timers.js:497:7) {  
0|app | status: undefined,  
0|app | displayName: 'RequestTimeout',  
0|app | body: undefined  
0|app | }  
0|app | constituencies undefined

_the code I am using is :_

const elastiClient = new elasticsearch.Client({

```
hosts: ['http://elasticsearch.tpconnects.com:9200', 'http://elasticsearch.tpconnects.in:9200'],

requestTimeout: 60000

```

});

const query = req.params.id

let body = {

```
size: 15,

from: 0,

query: {

  "multi_match" : {

    "query": query,

     "type": "phrase_prefix",

    "fields": ["iata_code", "country","city","name"]

    //"operator": "OR"

 }

}

```

}

elastiClient.search({index:'airports\_new', body:body, type:'cities\_list'})

.then(results =\> {

```
console.log(typeof(results.hits.hits));
res.send(results.hits.hits);

```

})

.catch(err=\>{

```
console.log(err)

res.send([]);

```

});

elastiClient.count({index: 'airports\_new',type: 'cities\_list'},function(err,resp,status) {

```
console.log("constituencies",resp);

```

});

In kibana also, I can access the data using search query. But only from production i cant access the data.  
Note: elastiClient instance is getting created properly. I consoled the instance in server. Details displayed properly. But after that using that instance, search is not running and giving request timeout error.

---

<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:** [December 22, 2020, 8:15am UTC](https://discuss.elastic.co/t/statuscodeerror-request-timeout-after-30000ms-in-node-js/256461/2 "2020-12-22T08:15:34Z")

</div>

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