# Connecting to elastic

**URL:** <https://discuss.elastic.co/t/connecting-to-elastic/342288>\
**Category:** Kibana\
**Created:** [September 4, 2023, 9:30pm UTC](https://discuss.elastic.co/t/connecting-to-elastic/342288 "2023-09-04T21:30:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guilhermitos](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@Guilhermitos](https://discuss.elastic.co/u/Guilhermitos)\
**Post date:** [September 4, 2023, 9:30pm UTC](https://discuss.elastic.co/t/connecting-to-elastic/342288/1 "2023-09-04T21:30:06Z")

</div>

Hi guys, i have some doubt about connecting elasticsearch on python, is it really needed to have ca\_certs? i have tried to use verify\_certs=False but i'm getting an error, in this case is SSLError([SSL: DH\_KEY\_TOO\_SMALL] dh key too small (\_ssl.c:1002))

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 4, 2023, 10:37pm UTC](https://discuss.elastic.co/t/connecting-to-elastic/342288/2 "2023-09-04T22:37:19Z")

</div>

Hi @Guilhermitos

Welcome to the community.

Please share your connection code

`verify_certs=False` \< Correct / Corrected

~~Pretty sure it a lower case `false`~~

---

<div class="post-metadata">

**Author:** ![Guilhermitos](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@Guilhermitos](https://discuss.elastic.co/u/Guilhermitos)\
**Post date:** [September 4, 2023, 10:58pm UTC](https://discuss.elastic.co/t/connecting-to-elastic/342288/3 "2023-09-04T22:58:37Z")

</div>

```auto
from elasticsearch import Elasticsearch
def connect_elasticsearch():

    es = Elasticsearch(

        [{'host': 'XXXXXX', 'port':XXXX, 'scheme':'https'}],
        basic_auth=("USER", "PASSWORD"),
        verify_certs=False
    )

    if es.ping():
        print('Conectado')
    else:
        print('Nao conectado')
    return es
connect_elasticsearch()

```

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 4, 2023, 11:34pm UTC](https://discuss.elastic.co/t/connecting-to-elastic/342288/4 "2023-09-04T23:34:28Z")

</div>

Ohhh apologies yes

`verify_certs=False` looks correct

What version client?  
What version Elasticsearch?

Can you just try the simple form version

```auto
client = Elasticsearch(
    "https://localhost:9200",
    basic_auth=("user", "password"),
    verify_certs=False

)

```

And to make sure, are you sure your cluster is running on HTTPS?

Can you curl from where the python client is to elasticsearch?

`curl -k -v -u user https://host:port`

---

<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:** [October 2, 2023, 11:35pm UTC](https://discuss.elastic.co/t/connecting-to-elastic/342288/5 "2023-10-02T23:35:27Z")

</div>

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