# Unable to connect using Spring Data library

**URL:** <https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742>\
**Category:** OpenSearch\
**Tags:** troubleshoot, configure\
**Created:** [February 5, 2024, 7:53pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742 "2024-02-05T19:53:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![germanflighel](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@germanflighel](https://forum.opensearch.org/u/germanflighel)\
**Post date:** [February 5, 2024, 7:53pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/1 "2024-02-05T19:53:51Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
OS 1.0.0  
Spring Data OS 1.3.0

**Describe the issue** :  
I’m getting a 400 response on application startup which makes it fail to do so.  
The request being performed a HEAD request to check if an index exists, which is done on startup when declaring a OS Repository, which is what I expect. The index does not exist, but such response is docuemente as 404 response

**Configuration** :

**Relevant Logs or Screenshots** :

```auto
Caused by: org.springframework.data.elasticsearch.UncategorizedElasticsearchException: method [HEAD], host [http://vpc-search-trx-api-ufiwzrpmi5ng7nyd4tbbzu534q.us-east-1.es.amazonaws.com:443], URI [/transactions?ignore_throttled=false&ignore_unavailable=false&expand_wildcards=open%2Cclosed&allow_no_indices=false], status line [HTTP/1.1 400 Bad Request]

```

---

<div class="post-metadata">

**Author:** ![germanflighel](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@germanflighel](https://forum.opensearch.org/u/germanflighel)\
**Post date:** [February 5, 2024, 8:59pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/2 "2024-02-05T20:59:37Z")

</div>

I was able to test the connection using ElasticSearchOperations, and perfoming the same requests, to check if the index exists, gave me a 200 response. Could this be related to an issue when starting up the repository? Is there a different behaviour when creating a Repository?

Let me know how can I contribute and help fix this!

---

<div class="post-metadata">

**Author:** ![reta](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@reta](https://forum.opensearch.org/u/reta)\
**Post date:** [February 5, 2024, 9:30pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/3 "2024-02-05T21:30:56Z")

</div>

Hi @germanflighel , could you please run the same URL using `curl` ? Wondering where the problem is …

---

<div class="post-metadata">

**Author:** ![germanflighel](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@germanflighel](https://forum.opensearch.org/u/germanflighel)\
**Post date:** [February 5, 2024, 9:46pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/4 "2024-02-05T21:46:09Z")

</div>

> [@germanflighel](#):
>
> `http://vpc-search-trx-api-ufiwzrpmi5ng7nyd4tbbzu534q.us-east-1.es.amazonaws.com:443`

Unfortunately, the endpoint is behind a VPC, and I’m not able to `curl` it. It is only accesible to the deployed applications. FYI, its using Kubernetes on EKS

---

<div class="post-metadata">

**Author:** ![reta](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@reta](https://forum.opensearch.org/u/reta)\
**Post date:** [February 5, 2024, 9:54pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/5 "2024-02-05T21:54:00Z")

</div>

Gotcha, I will try to reproduce the problem and get back to you

---

<div class="post-metadata">

**Author:** ![reta](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@reta](https://forum.opensearch.org/u/reta)\
**Post date:** [February 6, 2024, 1:57pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/6 "2024-02-06T13:57:55Z")

</div>

@germanflighel I am unfortunately unable to reproduce the issue using standalone Docker server (opensearchproject/opensearch:1.0.0) and Spring Data Opensearch 1.3.0. If you could reproduce the issue locally, please share the steps. Thank you.

---

<div class="post-metadata">

**Author:** ![germanflighel](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@germanflighel](https://forum.opensearch.org/u/germanflighel)\
**Post date:** [February 7, 2024, 4:16pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/7 "2024-02-07T16:16:33Z")

</div>

I’ll try to do it, but I had some trouble doing so.  
Just to give you an idea: Since the error is only happening when using the repository, my guess is that the setup of such beans might not use exactly the same configuration for requests as the `ElasticSearchOperations` object. Could this be the case?

---

<div class="post-metadata">

**Author:** ![reta](https://avatars.discourse-cdn.com/v4/letter/r/cdc98d/32.png) [@reta](https://forum.opensearch.org/u/reta)\
**Post date:** [February 8, 2024, 3:03pm UTC](https://forum.opensearch.org/t/unable-to-connect-using-spring-data-library/17742/8 "2024-02-08T15:03:33Z")

</div>

> Just to give you an idea: Since the error is only happening when using the repository, my guess is that the setup of such beans might not use exactly the same configuration for requests as the `ElasticSearchOperations` object. Could this be the case?

Apologies, I am not following what configuration you mean, the `ElasticSearchOperations` is provided by Spring Data OpenSearch for OpenSearch the same way it is provided by Spring Data Elasticsearch for Elasticsearch. The configuration (at large) is used to connect to the right cluster and it seems like you don’t have connection issues.
