Can't connect to Elasticsearch with Node.Js on Kubernetes (socket hang up)
See original GitHub issueI have a NodeJs application running inside a Kubernetes cluster. I’ve also followed the official steps to setup Elasticsearch on Kubernetes.
I am not sure if this has actually something to do with elasticsearch-js or if I am doing something wrong here.
Issue
I am unable to connect to the Elasticsearch cluster. I get this error:
ConnectionError: socket hang up
This is a code snippet of my connection:
const client = new elasticsearch.Client({
node: process.env.elasticsearch_node, // http://elasticsearch-es-http.default.svc.cluster.local:9200
});
Minimal reproduction
I’ve created a minimal reproduction of this issue here: https://github.com/flolu/elasticsearch-k8s-connection. (Setup instructions are in the README)
Basically, everything works fine when running Elasticsearch inside Docker compose, but I can’t connect when running inside Kubernetes.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Can't connect to Elasticsearch with Node.Js on Kubernetes ...
The solution is to configure SSL and the Elastic user when creating the Client const client = new elasticsearch.Client({ node: ...
Read more >"message":"socket hang up" in kibana logs - Elastic Discuss
i am getting below error in the kibana logs continuously for every second. The error is logged even when there is no use....
Read more >How to handle a socket hang up error in Node.js usually - Quora
Close the connection if you have opened any for connecting to database after your work is done. Most of the times this is...
Read more >Hang in There! (A solution to socket hang up) - Medium
(A solution to socket hang up). Recently, while watching a YouTube video about how to create a Node.js backend (Building a RESTful API...
Read more >Unable to retrieve version information from Elasticsearch nodes
Typically, you'll see the “Unable to version information Elasticsearch nodes” message when Kibana can't connect to one of the hosts included in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Given that you are using a self-signed certificate, you should also set
rejectUnauthorized
tofalse
:You can find the SSL documentation here.
Glad you were able to sort it out! Yeah, it’s fine to use it as long as you trust that certificate. By default, Node.js rejects certificates that didn’t use an official CA authority, but given that you have created that cert via Elasticsearch, it’s safe to use.
Closing this, feel free to reopen if you have other questions! 😃