Python Elasticsearch Client Authentication - Connection Refused

Hello!!
How is going?
I'm using python client to connect to my elasticsearch database host at IBM Cloud's Openshift Instance. Then when I try to connect to it I got several errors.

About my elasticsearch database:
Version: 7.6.2
Security: Basic without HTTPS, nor SSL, nor Certificates (current limitations of the cluster, pending fixture, no possibility of implementing SSL nor Elastic Certificates on the cluster side for now)
Exposed on Port: 9200

Here is my code:

from elasticsearch import Elasticsearch
from elasticsearch import RequestsHttpConnection
es = Elasticsearch(
    'http://my_elastic_host',
    http_auth=('my-usr', 'my-pass')
)
print("Elastic Info:")
print(es.info())

The error:

ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x110931c50>: Failed to establish a new connection: [Errno 61] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x110931c50>: Failed to establish a new connection: [Errno 61] Connection refused)

I really don't know why this is happening.

I've tried the same similar thing with curl, and I can access my database, execute reminded, drop index, and all commands. And my host doesn't even need the port declaration, it is simply:

curl -H "Authorization: Basic Base64Token" -H "Content-Type: application/json" -XPOST host/_reindex -d '{"source": {"index": "old_index"},"dest": {"index": "new_index"}}'

The curl works perfectly fine, why am I having so many difficulties with Python's Client?
Can anyone help me, please? This is part of a POC that has ELK stack as its main feature, and I want to prove that we can harness data and do some machine learning, or specific future experiments over it with Python (curl is good, but, not adequate to what we want in future).

1 Like

Forget about it please!!
Solved it already... in the end it was using the port 80, and I probably need a firewall rule to expose the 9200 outbounds...
Thanks anyway ahaha

Welcome! :smiley:

Glad you found the solution, and thanks heaps for sharing it too.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.