# Problem of connecting python client with elasticsearch

**URL:** <https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 26, 2023, 1:21pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437 "2023-05-26T13:21:12Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![waqar\_jamali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqar_jamali/32/121494_2.png) [@waqar\_jamali](https://discuss.elastic.co/u/waqar_jamali)\
**Post date:** [May 26, 2023, 1:21pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/1 "2023-05-26T13:21:13Z")

</div>

I am unable to connect with elastic using python client  
The code which run with no issue is  
`from elasticsearch import Elasticsearch`  
`es = Elasticsearch(['http://<your_ip_address>:<your_port>'])`  
(I use my ip and port which is running correctly in browser)  
but when I run  
`response = es.cluster.health()`  
I get

> Traceback (most recent call last):  
> File "", line 1, in   
> File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch\_sync\client\utils.py", line 414, in wrapped  
> return api(\*args, \*\*kwargs)  
> ^^^^^^^^^^^^^^^^^^^^  
> File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch\_sync\client\cluster.py", line 464, in health  
> return self.perform\_request( # type: ignore[return-value]  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch\_sync\client\_base.py", line 389, in perform\_request  
> return self.\_client.perform\_request(  
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
> File "C:\Users\waqar.ahmed\AppData\Local\Programs\Python\Python311\Lib\site-packages\elasticsearch\_sync\client\_base.py", line 331, in perform\_request  
> raise UnsupportedProductError(  
> elasticsearch.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [May 26, 2023, 1:26pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/2 "2023-05-26T13:26:46Z")

</div>

Hi @waqar_jamali,

Welcome to the community!

> [@waqar\_jamali](#):
>
> elasticsearch.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product

The error is suggesting you're not connecting to an Elasticsearch server. Have you double checked your host and post settings in your initialization?

Are you making use of OpenSearch at all? Can you share which version of the Python client you are using and which version of Elasticsearch you are trying to connect to?

---

<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:** [May 26, 2023, 1:26pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/3 "2023-05-26T13:26:46Z")

</div>

OpenSearch/OpenDistro are AWS run products and differ from the original Elasticsearch and Kibana products that Elastic builds and maintains. You may need to contact them directly for further assistance.

(This is an automated response from your friendly Elastic bot. Please report this post if you have any suggestions or concerns :elasticheart: )

---

<div class="post-metadata">

**Author:** ![waqar\_jamali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqar_jamali/32/121494_2.png) [@waqar\_jamali](https://discuss.elastic.co/u/waqar_jamali)\
**Post date:** [May 26, 2023, 1:38pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/4 "2023-05-26T13:38:03Z")

</div>

Hi @carly.richmond  
Here is the version of my elastic "7.10.2"  
and Elasticsearch python version `Elasticsearch Python client version: (8, 6, 2)`

The 'import request' is working fine

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [May 26, 2023, 1:43pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/5 "2023-05-26T13:43:28Z")

</div>

Thanks for confirming. Given the version of Elasticsearch you are trying to connect to, I would recommend trying version 7 of the Elasticsearch Python client as from the docs given [we don't guarantee full backward compatibility](https://www.elastic.co/guide/en/elasticsearch/client/python-api/7.17/overview.html#_compatibility):

> Language clients are forward compatible; meaning that clients support communicating with greater or equal minor versions of Elasticsearch. Elasticsearch language clients are only backwards compatible with default distributions and without guarantees made.

Let us know if the alternative version fixes the problem.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 26, 2023, 1:45pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/6 "2023-05-26T13:45:25Z")

</div>

> [@waqar\_jamali](#):
>
> Here is the version of my elastic "7.10.2"

But it is the Elastic distribution or the OSS?

What is the result of `curl http://your-ip:your-port` ?

If I'm not wrong, the Elastic python client does not work with the OSS distribution anymore in the latests releases.

---

<div class="post-metadata">

**Author:** ![waqar\_jamali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqar_jamali/32/121494_2.png) [@waqar\_jamali](https://discuss.elastic.co/u/waqar_jamali)\
**Post date:** [May 26, 2023, 1:48pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/7 "2023-05-26T13:48:02Z")

</div>

Hi @leandrojmp  
The curl response is

```auto
"version" : {
    "number" : "7.10.2",
   .
   .
   .
    "lucene_version" : "8.7.0",
    .

  },
  "tagline" : "You Know, for Search"

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 26, 2023, 1:48pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/8 "2023-05-26T13:48:55Z")

</div>

> [@waqar\_jamali](#):
>
> How do I know it is OSS?

Run a curl to your elasticsearch and paste the results.

`curl http://your-elastic-ip:your-elastic-port`

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 26, 2023, 1:50pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/9 "2023-05-26T13:50:38Z")

</div>

> [@waqar\_jamali](#):
>
> The curl response is

You need to share the entire response, there are more information in the response, what you shared is not enough, you need to share the `build_` fields from the response.

---

<div class="post-metadata">

**Author:** ![waqar\_jamali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqar_jamali/32/121494_2.png) [@waqar\_jamali](https://discuss.elastic.co/u/waqar_jamali)\
**Post date:** [May 26, 2023, 1:55pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/10 "2023-05-26T13:55:45Z")

</div>

> [@carly.richmond](#):
>
> Thanks for confirming. Given the version of Elasticsearch you are trying to connect to, I would recommend trying version 7 of the Elasticsearch Python client as from the docs given [we don't guarantee full backward compatibility](https://www.elastic.co/guide/en/elasticsearch/client/python-api/7.17/overview.html#_compatibility):

Thank you version 7.9.0 working

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 26, 2023, 1:58pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/11 "2023-05-26T13:58:16Z")

</div>

> [@waqar\_jamali](#):
>
> Thank you version 7.9.0 working

If version 7.9 of the client works, you are probably using the oss version, you can check it looking at the value of `build_flavor` when you the curl mentioned before.

---

<div class="post-metadata">

**Author:** ![waqar\_jamali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/waqar_jamali/32/121494_2.png) [@waqar\_jamali](https://discuss.elastic.co/u/waqar_jamali)\
**Post date:** [May 26, 2023, 2:00pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/12 "2023-05-26T14:00:29Z")

</div>

It is "default"

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 26, 2023, 2:10pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/13 "2023-05-26T14:10:12Z")

</div>

Weird, it should've work then since 7.10.2 uses the basic license.

---

<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:** [June 23, 2023, 2:10pm UTC](https://discuss.elastic.co/t/problem-of-connecting-python-client-with-elasticsearch/334437/14 "2023-06-23T14:10:36Z")

</div>

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