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?
Did you configure authentication for the client? (maybe not added to the example?) Check out the docs about connecting here.. You can either use a certificate, or a password, or ideally an API-Key.
Connecting via http only works if you specifically disabled security; so unless you did, that's probably your issue.
Good luck! Iulia