Why does elastic raise this exception "elasticsearch.exceptions.ConnectionError: ConnectionError(check_hostname requires server_hostname)"? Why does elastic raise this exception "elasticsearch.exceptions.ConnectionError: ConnectionError(check_hostname requires server_hostname)"? elasticsearch elasticsearch

Why does elastic raise this exception "elasticsearch.exceptions.ConnectionError: ConnectionError(check_hostname requires server_hostname)"?


Unfortunately, I also met such issue.

By default, the value of check_hostname in context is True, so you have to specify the server_hostname. Here is a simple solution, just add the following line after you create context

context.check_hostname = False

It should work without any issue


You don't mention the port in your example. Please verify the tutorial you mentioned and following snippet:

es = Elasticsearch(    ['localhost', 'otherhost'],    http_auth=('user', 'secret'),    scheme="https",    port=443,)


By doing context.check_hostname = False you make the connection insecure.

Use this constructor instead:

Elasticsearch(   hosts=['ip_address'],,   http_auth=('elastic', 'pass'),   use_ssl=True,   verify_certs=True,   port=9200, #make sure of the port elasticsearch is using   ca_certs='/Users/raphaeldelio/ca.crt')