I am able to access the ElasticSearch via http://127.0.0.1:9200, however when trying to connect from the same machine via RestHighLevelClient I get the java.net.ConnectException: Connection refused.
try {
final BulkResponse response=this.restHighLevelClient.bulk(bulkRequest);
}
catch (final IOException exn) {
LOG.error("Bulk insert failed", exn);
}
The configuration class for Elastic search client is like below.
@Bean
public RestHighLevelClient restClient() {
return new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", "9200", "http")));
}
I have retained the default settings in elastic-search.yml file and debugged to be sure that host and port are correct. Any ideas please?
restHighLevelClient- NishantCONNECTION REFUSEDis the TCP error you will see when there is no application listening to the selected port. Check to see that you actually have a program running and bound to port 9200. - Matt Clark127.0.0.1instead oflocalhost? - Nishant