No living connections Error while Elasticsearch connections in nodejs
Solution 1
In case of Docker Container Environment after changing from http://localhost:9200 to http://ipaddress:9200 in docker-compose.yml
please change the following live in docker-compose.yml that is related to CORS
Change this ** http.cors.allow-origin=/https?://localhost(:[0-9]+)?/ ** into this
*- http.cors.allow-origin= **
Solution 2
I understand this question is quite old but I wanted to share how you can solve this problem.
- If you are locally using elasticsearch
First thing you must do is running elasticsearch on your machine.
Error: Request error, retrying -- connect ECONNREFUSED 127.0.0.1:9200
Because above message indicates that you're not running elasticsearch locally.
So, visit the link and follow the insturction.
- Docker environment
It gets much trickier here.
First, follow the instruction here.
And in case you're using node.js elasticsearch client, you have to specify elasticsearch host
as 172.24.0.1
.
If you use container_name
or private IP
of container
in docker-compose.yml
, it won't work.
Mohammad Shahadat Hossain
My name is Shahadat Hossain (dihan) and I am currently working as a software developer in R&D located in dhaka,Bangladesh. My interest in web & Mobile application development has turned into a passion which I want to monetize. I always enjoyed science, math, and technical things. I am always keen to learn new stuffs about technology and gain more and more knowledge because thirst is never satisfied. :) profile for Mohammad Shahadat Hossain at Stack Overflow, Q&A for professional and enthusiast programmers http://stackoverflow.com/users/flair/2318085.png%20?theme=dark
Updated on June 14, 2022Comments
-
Mohammad Shahadat Hossain almost 2 years
I am having this problem while connecting the elasticsearch connections.
var elasticsearch = require('elasticsearch'); var client = new elasticsearch.Client({ host: 'localhost:9200', log: 'trace'});
Elasticsearch ERROR: 2016-07-19T19:09:26Z Error: Request error, retrying -- connect ECONNREFUSED 127.0.0.1:9200 at Log.error (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/log.js:225:56) at checkRespForFailure (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/transport.js:195:18) at HttpConnector. (/root/git_build/FirstMoveChess/node_modules/elasticsearch/src/lib/connectors/http.js:154:7) at ClientRequest.bound (/root/git_build/FirstMoveChess/node_modules/lodash-node/modern/internals/baseBind.js:56:17) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at Socket.socketErrorListener (_http_client.js:308:9) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1272:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) Elasticsearch TRACE: 2016-07-19T19:09:27Z -> HEAD http://localhost:9200/
-
JDPeckham almost 5 yearsCan you tell me more about this 172.24.0.1 thing? I'm having trouble getting documents to create using localhost:9200 but I can browse to it just fine in chrome and it doesn't error right away but after 30-40 sec