Pradyumna Yogan
Pradyumna Yogan

Reputation: 37

Max retries exceeded - Elasticsearch

I am trying to establish an elasticsearch connection and creating an index. But i get the following error:

elasticsearch.exceptions.ConnectionError: ConnectionError(HTTPConnectionPool(host='localhost', port=9200): Max retries exceeded with url: /test-index (Caused by <class 'socket.error'>: [Errno 111] Connection refused)) caused by: MaxRetryError(HTTPConnectionPool(host='localhost', port=9200): Max retries exceeded with url: /test-index (Caused by <class 'socket.error'>: [Errno 111] Connection refused))

My code is as follows:

self.es = Elasticsearch(hosts=[{"host": "http://192.168.0.5:9200", "port": 9200}], timeout=10)

self.es.indices.create(index='test-index', ignore=400 )     

Upvotes: 1

Views: 6534

Answers (1)

Yasin Bahtiyar
Yasin Bahtiyar

Reputation: 2367

You do not configure the client correctly. It still tries to connect to localhost:9200. Since 9200 is the default port you can omit it. Try this instead:

self.es = Elasticsearch(hosts=[{"host": "192.168.0.5"}], timeout=10)

You can find more info in the documentation

Upvotes: 2

Related Questions