# Nodejs Elastic Client Setup is not working

**URL:** <https://discuss.elastic.co/t/nodejs-elastic-client-setup-is-not-working/266233>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 4, 2021, 12:25pm UTC](https://discuss.elastic.co/t/nodejs-elastic-client-setup-is-not-working/266233 "2021-03-04T12:25:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srinivas\_RK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srinivas_rk/32/83303_2.png) [@Srinivas\_RK](https://discuss.elastic.co/u/Srinivas_RK)\
**Post date:** [March 4, 2021, 12:25pm UTC](https://discuss.elastic.co/t/nodejs-elastic-client-setup-is-not-working/266233/1 "2021-03-04T12:25:33Z")

</div>

I have setup elastic using eck guide this is working fine. i was able to run logstash by importing certificates. now im trying to write a nodejs api project to use my elastic search. trying some examples from docs

```
const client = new Client({
    node: 'https://mynode.eastus.cloudapp.azure.com/',
    maxRetries: 5,
    requestTimeout: 60000,
    sniffOnStart: true,
    ssl: {
        ca: fs.readFileSync('./cacert.crt'),
        rejectUnauthorized: false,
    },
    auth: {
        password: ELASTIC_PWD,
        username: ELASTIC_USER
    }
});

```

However it seems my ssl config is not working

```
const result = await client.search({
      index: 'rush_idx',
      body: {
        query: {
          match: { isbn: "243453452" }
        }
      }
    });

```

the above request fails with

```
ResponseError: security_exception
    at onBody (D:\Workspaces\RL.Elastic-API\node_modules\@elastic\elasticsearch\lib\Transport.js:333:23)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  meta: {
    body: { error: [Object], status: 401 },
    statusCode: 401,
    headers: {
      'www-authenticate': 'Basic realm="security" charset="UTF-8", Bearer realm="security", ApiKey',
      'content-type': 'application/json; charset=UTF-8',
      'content-length': '549'
    },
    meta: {
      context: null,
      request: [Object],
      name: 'elasticsearch-js',
      connection: [Object],
      attempts: 0,
      aborted: false
    }
  }
}

```

can anybody tell what is correct way to configure ssl certificates in this case.

---

<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:** [April 1, 2021, 12:26pm UTC](https://discuss.elastic.co/t/nodejs-elastic-client-setup-is-not-working/266233/2 "2021-04-01T12:26:34Z")

</div>

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