While testing about with ES I'm struggling to get it to work with it's Python Client. I've followed the quick-start guide and set up local Docker containers running both ES and Kibana. To test the installation I used Postman to send some requests over to http://localhost:9200/ which responded with proper data.
The Python Client however fails to connect - installed it via Pip, imported it and set it up like so:
from elasticsearch import Elasticsearch
es = Elasticsearch(
['localhost'],
scheme="http",
port=9200,
)
if not es.ping():
raise BaseException("Connection failed")
The Error being thrown:
Failed to establish a new connection: [Errno 111] Connection refused
Here's an excerpt from my docker-compose:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.13.3
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elastic
Note that my python-container does not share the network with ES - does that play a notable role here?