Unable to connect Elastic Cloud to my python(FastApi) app

Here's my code:

from elasticsearch import Elasticsearch

es = Elasticsearch(
    cloud_id="cluster-1:dXMa5Fx...",
    http_auth=("elastic", "<password>"),
)
es.info()

#or

from elasticsearch import Elasticsearch

es = Elasticsearch(
    cloud_id="cluster-1:dXMa5Fx...",
    api_key=('key's id', 'the key')    #I also tried giving just the encoded api key instead of both the id and unencoded key
)
es.info()

#or

from elasticsearch import Elasticsearch

ELASTIC_PASSWORD = "MyPassword"

CLOUD_ID = "My_deployment:blahblahblah"

client = Elasticsearch(cloud_id=CLOUD_ID,
basic_auth=("enterprise_search", ELASTIC_PASSWORD) #not sure if my 
#username is 'elastic' or 'enterprise_search' but I did try both
)

# Successful response!
client.info()
# {'name': 'instance-0000000000', 'cluster_name': ...}

I get the same error in all the cases i.e.

NewConnectionError(<urllib3.connection.HTTPConnection object at 0x000001B33FE91AB0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it)

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