# NodeJS client unable to connect to Elasticsearch deployed in the same docker stack

**URL:** https://discuss.elastic.co/t/nodejs-client-unable-to-connect-to-elasticsearch-deployed-in-the-same-docker-stack/209013
**Category:** Elasticsearch
**Created:** [November 22, 2019, 6:12am UTC](https://discuss.elastic.co/t/nodejs-client-unable-to-connect-to-elasticsearch-deployed-in-the-same-docker-stack/209013 "2019-11-22T06:12:33Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Anish\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anish_kumar/32/58144_2.png) [@Anish\_Kumar](https://discuss.elastic.co/u/Anish_Kumar)
#### Post date: [November 22, 2019, 6:12am UTC](https://discuss.elastic.co/t/nodejs-client-unable-to-connect-to-elasticsearch-deployed-in-the-same-docker-stack/209013/1 "2019-11-22T06:12:33Z")

</div>

I have a docker stack deployment inside which I have elastic search deployed as a service. Now I have another NodeJS application inside the same docker stack deployed as service. I am using the Official elastic search Client (@elastic/elasticsearch ) to make calls to Elastic from my node application. Now I am able to connect to elastic using Normal REST call like "[http://elasticsearch:9200](http://elasticsearch:9200)"  
But the Client is not able to connect using this above URL.  
const { Client } = require('@elastic/elasticsearch');  
const client = new Client({ node: "[http://elasticsearch:9200](http://elasticsearch:9200)"});  
Anyway to get this working?.

HEre is my elastic service defined in my stack yml file.

elasticsearch:  
image: [docker.elastic.co/elasticsearch/elasticsearch:7.4.2](http://docker.elastic.co/elasticsearch/elasticsearch:7.4.2)  
environment:  
- cluster.name=elastic-unifyed-cluster-stage  
- bootstrap.memory\_lock=false  
- "ES\_JAVA\_OPTS=-Xms1024m -Xmx1024m"  
- "xpack.security.enabled=false"  
- "xpack.monitoring.enabled=false"  
- "xpack.watcher.enabled=false"  
- "network.host=0.0.0.0"  
- "discovery.zen.ping.unicast.hosts=elasticsearch"  
- "discovery.zen.minimum\_master\_nodes=3"  
volumes:  
- /apps/dockerdata/elastic:/usr/share/elasticsearch/data  
deploy:  
mode: global  
endpoint\_mode: dnsrr  
restart\_policy:  
condition: on-failure  
placement:  
constraints: [node.labels.elastic == true]

---

<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 20, 2019, 6:12am UTC](https://discuss.elastic.co/t/nodejs-client-unable-to-connect-to-elasticsearch-deployed-in-the-same-docker-stack/209013/2 "2019-12-20T06:12:40Z")

</div>

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