Home > Mobile >  Python API client for Elastic Search: can't connect due to Connection timed out
Python API client for Elastic Search: can't connect due to Connection timed out

Time:08-31

I am working with the Python API client for Elastic Search and I am trying to connect to it.

I create the client like this:

def setup_es():
    ES_USER = os.getenv("ES_USER")
    ES_PASS = os.getenv("ES_PASS")
    print(f"Setting up ES with HOST={ES_HOST}, USER={ES_USER}, PASS={ES_PASS}")
    return Elasticsearch([ES_HOST], basic_auth=(ES_USER, ES_PASS))

But whenever I try using the client, I always get a connection timed out error. For example:

   client.info()

or

    client.options(ignore_status=[400,404]).indices.delete(index=MY_INDEX)

Always produce:

***_transport.ConnectionTimeout: Connection timed out

I know the host, user and password are right. Am I missing something else? Any ideas please?

CodePudding user response:

I solved this issue by specifying port 443 in the elastic search host variable.

  • Related