# Elasticsearch With Haystack -Initial connection to Elasticsearch failed

**URL:** <https://discuss.huggingface.co/t/elasticsearch-with-haystack-initial-connection-to-elasticsearch-failed/17510>\
**Category:** 🤗 Course Projects\
**Created:** [May 4, 2022, 8:47am UTC](https://discuss.huggingface.co/t/elasticsearch-with-haystack-initial-connection-to-elasticsearch-failed/17510 "2022-05-04T08:47:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sh-rashtchi](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@sh-rashtchi](https://discuss.huggingface.co/u/sh-rashtchi)\
**Post date:** [May 4, 2022, 8:47am UTC](https://discuss.huggingface.co/t/elasticsearch-with-haystack-initial-connection-to-elasticsearch-failed/17510/1 "2022-05-04T08:47:07Z")

</div>

Hi

I am trying to run Chapter 7 to learn about Haystack for QA:

I am using Jupyter Notebook which is connected to my GCP VM : Debian GNU/Linux 9, Tesla V100  
I did install debian version  
but facing the following error : ConnectionError: Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at `[{'host': 'localhost', 'port': 9200}]` and that it has finished the initial ramp up (can take \> 30s).

!wget [https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86\_64.tar.gz](https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz)  
!wget [https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86\_64.tar.gz.sha512](https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.1.2-linux-x86_64.tar.gz.sha512)  
!shasum -a 512 -c elasticsearch-8.1.2-linux-x86\_64.tar.gz.sha512  
!tar -xzf elasticsearch-8.1.2-linux-x86\_64.tar.gz  
!cd elasticsearch-8.1.2/  
!pip install pymilvus  
import pymilvus  
import os  
from subprocess import Popen, PIPE, STDOUT

!chown -R daemon:daemon elasticsearch-8.1.2  
es\_server = Popen(args=[‘elasticsearch-8.1.2/bin/elasticsearch’])  
!sleep 30

from haystack.document\_store.elasticsearch import ElasticsearchDocumentStore

#document\_store = ElasticsearchDocumentStore(host=‘localhost’, port= 9201, username=’’, password=’’)  
document\_store = ElasticsearchDocumentStore(return\_embedding=True)

I would appreciate your support on this.

Shabnam

---

<div class="post-metadata">

**Author:** ![Ceiwh](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@Ceiwh](https://discuss.huggingface.co/u/Ceiwh)\
**Post date:** [January 18, 2023, 7:55am UTC](https://discuss.huggingface.co/t/elasticsearch-with-haystack-initial-connection-to-elasticsearch-failed/17510/2 "2023-01-18T07:55:41Z")

</div>

same problem here! I wonder if you have found a solution already?

---

<div class="post-metadata">

**Author:** ![Dakan](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Dakan](https://discuss.huggingface.co/u/Dakan)\
**Post date:** [February 2, 2023, 6:51am UTC](https://discuss.huggingface.co/t/elasticsearch-with-haystack-initial-connection-to-elasticsearch-failed/17510/3 "2023-02-02T06:51:12Z")

</div>

Hi! the solution is launch ES:

```auto
from haystack.utils import launch_es
launch_es()

```

Before launching ES, we need to install docker to run ES locally, [here](https://docs.docker.com/engine/install/ubuntu/) the link to install [docker](https://docs.docker.com/engine/install/ubuntu/)  
After Docker installed, we need to change permission to use it as $USER:

```auto
sudo usermod -aG docker $USER
sudo reboot

```

Thats all:)

---

<div class="post-metadata">

**Author:** ![jonghwanbaek1](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@jonghwanbaek1](https://discuss.huggingface.co/u/jonghwanbaek1)\
**Post date:** [April 15, 2024, 11:40am UTC](https://discuss.huggingface.co/t/elasticsearch-with-haystack-initial-connection-to-elasticsearch-failed/17510/4 "2024-04-15T11:40:14Z")

</div>

Hi,

After launch\_es(), I saw the following error messages.  
Can you help me for this problems.

Of course, I changed username using ‘usermod’

**TypeError: create() got an unexpected keyword argument ‘mappings’**

#curl -X GET “localhost:9200/?pretty”

{  
“name” : “ac91bb8c9894”,  
“cluster\_name” : “docker-cluster”,  
“cluster\_uuid” : “Zb5y5OaSQtGIuBVB-I3POQ”,  
“version” : {  
“number” : “7.17.6”,  
“build\_flavor” : “default”,  
“build\_type” : “docker”,  
“build\_hash” : “f65e9d338dc1d07b642e14a27f338990148ee5b6”,  
“build\_date” : “2022-08-23T11:08:48.893373482Z”,  
“build\_snapshot” : false,  
“lucene\_version” : “8.11.1”,  
“minimum\_wire\_compatibility\_version” : “6.8.0”,  
“minimum\_index\_compatibility\_version” : “6.0.0-beta1”  
},  
“tagline” : “You Know, for Search”  
}

Thanks a lot in advance.
