Elastic Search Connection error

Hi every one I have installed elastic search through docker-compose on a machine. The version of elastic search in the yaml file is 1.11.0 and from python withn pyelasticsearch 7.6.0 I im tryig to get all the indices from the elastic search server

try:
        es = Elasticsearch([ELASTIC_SEARCH_SERVER])
        print("Connection to ES Server successful")
    except:
        print("Unable to connect to server")
        exit(1)

    # get all wazuh indexes
    lsindex = []
    for i in es.indices.get_alias("*"):
       if i.startswith(ALERTS_PREFIX):

The code gives me the following error
ConnectionError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))) caused by: ProtocolError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')))

I tried ping to to the elastic search server and everything is fine. Can anyone help me debug?

Can you curl -H "Content-Type: application/json" ESIP:9200/?

The host I installed the elastic search server is 192.168.2.12. From the another local machine 192.168.2.4 can access the elastic search server. So the problem is that the host server cannot resolve localhost. Trying to find a solution. I am bypassing ssl certificates. I am using the following docker file Wazuh

I can access the elastic search server successfully from the url: https://admin:admin@localhost:9200
and also from python I successfully connect to the elastic search server. But when the code comes to es.indices.get_alias(*) there is the error connection could not be established 111

It'd help if you could post all of your code.

The connection to the elastic search server is sucessfully
l but I cannot get the indices

try:
        #ELASTIC_SEARCH_SERVER==https://admin:admin@localhost:9200
        es = Elasticsearch(ELASTIC_SEARCH_SERVER,
                           use_ssl = False,
                           ca_certs=False,
                           verify_certs=False)

        print("Connection to ES Server successful")
    except:
        print("Unable to connect to server")
        exit(1)

    # get all wazuh indexes
    lsindex = []
    for i in es.indices.get_alias("*"):
        if i.startswith(ALERTS_PREFIX):
            lsindex.append(i)

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