Elasticsearch automatically closes connection as soon as I run my Java Springboot program

Did you set port 9300.... Can you try 9200

spring.data.elasticsearch.cluster-nodes=localhost:9200

You can not connect to the 9300 transport client port in Elasticsearch 7.x+

Looks like you are running Elasticsearch 8.1.3 ... Definitely can not connect to the transport client.

https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.transport

What version of spring data Elasticsearch

https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/

Your going to need to use the high level rest client

https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.rest

Which I think is already deprecated see

1 Like