1

I was trying to learn and use the elasticsearch Python client on Windows and got stuck with a connection error.

I ran the bin\elasticsearch.bat file that comes with the .zip from the official page: https://www.elastic.co/downloads/elasticsearch

I opened a Jupyter notebook and tried to run:

from elasticsearch import Elasticsearch
es = Elasticsearch(hosts=["http://localhost:9200"])
es.indices.create(index="users")

It returned the following error:

ConnectionError: Connection error caused by: ConnectionError(Connection error caused by: ProtocolError(('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))))

Is it a problem of not having a correct JSON format when communicating? How to solve it?

Rui Melo
  • 47
  • 9

1 Answers1

-1

Probably, you're using Docker container of Jupyter notebook. So, from notebook you won't connect to "localhost". Try to use internal Docker network URL. You can find it in container inspecting. I got the same issue, and could resolve it using VSCode extension for Docker agent. Try to get URL from here