# ConnectionError: connect ECONNREFUSED

**URL:** <https://discuss.elastic.co/t/connectionerror-connect-econnrefused/289287>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 16, 2021, 9:28am UTC](https://discuss.elastic.co/t/connectionerror-connect-econnrefused/289287 "2021-11-16T09:28:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maks\_7v](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maks_7v/32/97067_2.png) [@Maks\_7v](https://discuss.elastic.co/u/Maks_7v)\
**Post date:** [November 16, 2021, 9:28am UTC](https://discuss.elastic.co/t/connectionerror-connect-econnrefused/289287/1 "2021-11-16T09:28:01Z")

</div>

I've configured Elasticsearch in k8s with a separate master, data, and ingest nodes.  
`xpack.security.enabled` is set to `true`  
I'm trying to connect a Node.js application to Elasticsearch using Elasticsearch-js client but it fails to connect to elastic.  
Error looks like this:  
`ConnectionError: connect ECONNREFUSED`  
it appears on `elasticClient.ping()`  
There are no other errors logged from my Node.js application, nor errors in ingest nodes logs.

I tried to generate passwords for default users and use basic authentication connecting to elastic:  
`const elasticClient = new Client({ node: "http://elastic:mypassword@es-ingest.es.svc.cluster.local:9200"});`  
But with basic auth - there is the same 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 14, 2021, 9:28am UTC](https://discuss.elastic.co/t/connectionerror-connect-econnrefused/289287/2 "2021-12-14T09:28:13Z")

</div>

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