# Authenticate with user:passowrd with elasticsearch node.js module

**URL:** <https://discuss.elastic.co/t/authenticate-with-user-passowrd-with-elasticsearch-node-js-module/191627>\
**Category:** Elasticsearch\
**Created:** [July 22, 2019, 11:42am UTC](https://discuss.elastic.co/t/authenticate-with-user-passowrd-with-elasticsearch-node-js-module/191627 "2019-07-22T11:42:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yonatan\_Omer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yonatan_omer/32/42450_2.png) [@Yonatan\_Omer](https://discuss.elastic.co/u/Yonatan_Omer)\
**Post date:** [July 22, 2019, 11:42am UTC](https://discuss.elastic.co/t/authenticate-with-user-passowrd-with-elasticsearch-node-js-module/191627/1 "2019-07-22T11:42:35Z")

</div>

I can successfully connect to ES from Java and Curl, bu using 'myUserName:myPassword'  
but when initializing the node.js client as shown in the doc, i receive 403

const { Client } = require('@elastic/elasticsearch')  
const client = new Client({ node: '[https://myUserName:myPassword@myEsHostName:9200](https://myUserName:myPassword@myEsHostName:9200)' })

{ ResponseError: security\_exception  
at IncomingMessage.response.on (d:\log\_analyser\LogQualUI\node\_modules@elastic\elasticsearch\lib\Transport.js:302:25)  
at emitNone (events.js:111:20)  
at IncomingMessage.emit (events.js:208:7)  
at endReadableNT (\_stream\_readable.js:1064:12)  
at \_combinedTickCallback (internal/process/next\_tick.js:139:11)  
at process.\_tickCallback (internal/process/next\_tick.js:181:9)  
name: 'ResponseError',  
meta:  
{ body: { error: [Object], status: 403 },

---

<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:** [August 19, 2019, 11:42am UTC](https://discuss.elastic.co/t/authenticate-with-user-passowrd-with-elasticsearch-node-js-module/191627/2 "2019-08-19T11:42:55Z")

</div>

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