# Unable to Connect to Server from Spring boot application in es 8.12

**URL:** <https://discuss.elastic.co/t/unable-to-connect-to-server-from-spring-boot-application-in-es-8-12/351494>\
**Category:** Elasticsearch\
**Tags:** language-clients, vector-search\
**Created:** [January 21, 2024, 6:18am UTC](https://discuss.elastic.co/t/unable-to-connect-to-server-from-spring-boot-application-in-es-8-12/351494 "2024-01-21T06:18:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Teltia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_teltia/32/122447_2.png) [@Aditya\_Teltia](https://discuss.elastic.co/u/Aditya_Teltia)\
**Post date:** [January 21, 2024, 6:18am UTC](https://discuss.elastic.co/t/unable-to-connect-to-server-from-spring-boot-application-in-es-8-12/351494/1 "2024-01-21T06:18:19Z")

</div>

While I am able to connect for version es 7.17 but when I am doing the same for version 8.x I am unable to connect.

I have to connect to 8.x since I want to use KNN query which it seems is only available in 8.x and later versions.

Below is my Elasticsearch Config file while I am connecting to 7.17. What needs to be fixed or added in this so that I am able to connect to 8.x version since there is a requirement of username, password and ca\_cert in that

```auto
package com.similarity.match.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticsearchConfig {

    @Value("${elasticsearch.host}")
    private String host;

    @Value("${elasticsearch.port}")
    private int port;

    @Value("${elasticsearch.scheme}")
    private String scheme;

    @Bean(destroyMethod = "close")
    public RestHighLevelClient restHighLevelClient() {

        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(host, port, scheme)
                ).setHttpClientConfigCallback(httpAsyncClientBuilder ->
                        httpAsyncClientBuilder));
    }
}

```

Also how can I write a knn query using Java RestHighLevelClient. Wasn't able to find any resource for the same online.

---

<div class="post-metadata">

**Author:** ![Sunile\_Manjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunile_manjee/32/111461_2.png) [@Sunile\_Manjee](https://discuss.elastic.co/u/Sunile_Manjee)\
**Post date:** [January 22, 2024, 4:09am UTC](https://discuss.elastic.co/t/unable-to-connect-to-server-from-spring-boot-application-in-es-8-12/351494/2 "2024-01-22T04:09:50Z")

</div>

> [@Aditya\_Teltia](#):
>
> `RestHighLevelClient`

Have you considered migrating from RHLC to ES java API? [Migrating from the High Level Rest Client | Elasticsearch Java API Client [8.12] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/8.12/migrate-hlrc.html)

---

<div class="post-metadata">

**Author:** ![Aditya\_Teltia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aditya_teltia/32/122447_2.png) [@Aditya\_Teltia](https://discuss.elastic.co/u/Aditya_Teltia)\
**Post date:** [January 22, 2024, 10:40am UTC](https://discuss.elastic.co/t/unable-to-connect-to-server-from-spring-boot-application-in-es-8-12/351494/3 "2024-01-22T10:40:15Z")

</div>

I tried doing the same but I getting that it is abstract and cannot be instantiated. But in the documentation it is done the way I have instantiated it.

 ![Screenshot 2024-01-22 at 4.07.49 PM](https://us1.discourse-cdn.com/elastic/original/3X/6/b/6bc8fc86e46101a872c0e8fc965b7e24478f8402.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 19, 2024, 10:40am UTC](https://discuss.elastic.co/t/unable-to-connect-to-server-from-spring-boot-application-in-es-8-12/351494/4 "2024-02-19T10:40:57Z")

</div>

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