Elastic Search and Python Connection

Hi,

I am trying to connect elastic search thru python, However I get below connection error message.

elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x0000021B1AA72DD8>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x0000021B1AA72DD8>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed)

My script is as follows.

from elasticsearch import Elasticsearch
es=Elasticsearch(host="http://host/",port= 9200)
print(es.info())

Thanks.

Is that the real address?

http://**/

Hi I have suppressed the address (confidential) it's elastic search hosted on AWS.
Connectivity is fine while connecting thru postman, elastic .net libraries and required access is in place.

Should work while doing same thru python?
Am I missing any configuration here?

Do you mean that you are hosting it by yourself or running Elasticsearch as a service by AWS?
More than that my question is actually: do you run your elasticsearch cluster without any security? Looking at the code you paste, it sounds like this. Unless you are doing something like:

es = Elasticsearch(['https://user:secret@localhost:443'])

The fact that you have suppressed the address in your post is hiding maybe an important mistake. But I can't really tell here.

Just a guess then, may be try:

es = Elasticsearch(
    ['host'],
    scheme="http",
    port=9200,
)

To answer, running Elastic Search as a service by AWS.
I am running from in AWS workstation itself, so no auth cert required.
Below is the snippet.

from elasticsearch import Elasticsearch
es=Elasticsearch(['https://abc.develop.uat/:9200'])
print(es.info())

Thanks.

So it's not the same form as it was previously? It's now https, without setting the port as a parameter?

es=Elasticsearch(host="http://host/",port= 9200)

is not exactly:

es=Elasticsearch(['https://abc.develop.uat/:9200'])

Which is wrong BTW...
It should probably be:

es=Elasticsearch(['https://abc.develop.uat:9200/'])

As this is not the real code I'm afraid I can't help.

BTW did you look at https://www.elastic.co/cloud and https://aws.amazon.com/marketplace/pp/B01N6YCISK ?

Cloud by elastic is one way to have access to all features, all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL, Canvas, APM, Logs UI, Infra UI, SIEM, Maps UI and what is coming next :slight_smile: ...

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