Elasticsearch With Node.js throwing an Error: connect EADDRNOTAVAIL

I am using Elasticsearch6.8.3 docker on an AWS ec2 machine for the production environment. For this purpose, I have installed the Elasticsearch via docker compose. In a microservice architecture many of the other services using different languages like PHP and Python, are just working fine. But When it comes to Node.js client it starts throwing this error :

Connect EADDRNOTAVAIL IP_ADDRESS:9200 - Local (IP_ADDRESS:0)
at onResponse (/var/app/current/node_modules/@elastic/elasticsearch/lib/Transport.js:228:13)
at ClientRequest.<anonymous> 
(/var/app/current/node_modules/@elastic/elasticsearch/lib/Connection.js:113:9)
at ClientRequest.emit (events.js:314:20)
at ClientRequest.EventEmitter.emit (domain.js:483:12)
at Socket.socketErrorListener (_http_client.js:427:9)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)

I have also verified the docker container is up and running at that time, as it was accessible through the web browser. I am not sure about the problem that is it a Node client issue or there is something wrong with docker networking? Also right after restarting the docker container, everything started working

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