# Elastic Search Connection error

**URL:** https://discuss.elastic.co/t/elastic-search-connection-error/261348
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [January 17, 2021, 11:38am UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348 "2021-01-17T11:38:05Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Tlm\_Konstantinos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tlm_konstantinos/32/78397_2.png) [@Tlm\_Konstantinos](https://discuss.elastic.co/u/Tlm_Konstantinos)
#### Post date: [January 17, 2021, 11:38am UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/1 "2021-01-17T11:38:05Z")

</div>

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

```auto
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?

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [January 17, 2021, 10:37pm UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/2 "2021-01-17T22:37:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Tlm\_Konstantinos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tlm_konstantinos/32/78397_2.png) [@Tlm\_Konstantinos](https://discuss.elastic.co/u/Tlm_Konstantinos)
#### Post date: [January 18, 2021, 7:47pm UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/3 "2021-01-18T19:47:38Z")

</div>

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](https://github.com/wazuh/wazuh-docker/blob/master/docker-compose.yml)

---

<div class="post-metadata">

### Author: ![Tlm\_Konstantinos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tlm_konstantinos/32/78397_2.png) [@Tlm\_Konstantinos](https://discuss.elastic.co/u/Tlm_Konstantinos)
#### Post date: [January 19, 2021, 5:26pm UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/4 "2021-01-19T17:26:40Z")

</div>

I can access the elastic search server successfully from the url: [https://admin:admin@localhost:9200](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

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [January 19, 2021, 7:20pm UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/5 "2021-01-19T19:20:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Tlm\_Konstantinos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tlm_konstantinos/32/78397_2.png) [@Tlm\_Konstantinos](https://discuss.elastic.co/u/Tlm_Konstantinos)
#### Post date: [January 21, 2021, 2:07pm UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/6 "2021-01-21T14:07:16Z")

</div>

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

```auto
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)

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 18, 2021, 2:07pm UTC](https://discuss.elastic.co/t/elastic-search-connection-error/261348/7 "2021-02-18T14:07:26Z")

</div>

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