# Python Elasticsearch Client Authentication - Connection Refused

**URL:** https://discuss.elastic.co/t/python-elasticsearch-client-authentication-connection-refused/233211
**Category:** Elasticsearch
**Created:** [May 18, 2020, 10:20pm UTC](https://discuss.elastic.co/t/python-elasticsearch-client-authentication-connection-refused/233211 "2020-05-18T22:20:30Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Fernando1](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@Fernando1](https://discuss.elastic.co/u/Fernando1)
#### Post date: [May 18, 2020, 10:20pm UTC](https://discuss.elastic.co/t/python-elasticsearch-client-authentication-connection-refused/233211/1 "2020-05-18T22:20:30Z")

</div>

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:

```auto
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:

```auto
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).

---

<div class="post-metadata">

### Author: ![Fernando1](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@Fernando1](https://discuss.elastic.co/u/Fernando1)
#### Post date: [May 18, 2020, 10:46pm UTC](https://discuss.elastic.co/t/python-elasticsearch-client-authentication-connection-refused/233211/2 "2020-05-18T22:46:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [May 18, 2020, 10:46pm UTC](https://discuss.elastic.co/t/python-elasticsearch-client-authentication-connection-refused/233211/3 "2020-05-18T22:46:56Z")

</div>

Welcome! 😃

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 15, 2020, 10:47pm UTC](https://discuss.elastic.co/t/python-elasticsearch-client-authentication-connection-refused/233211/4 "2020-06-15T22:47:03Z")

</div>

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