# Python client send data to Elastic cloud refused

**URL:** https://discuss.elastic.co/t/python-client-send-data-to-elastic-cloud-refused/270853
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [April 21, 2021, 2:04pm UTC](https://discuss.elastic.co/t/python-client-send-data-to-elastic-cloud-refused/270853 "2021-04-21T14:04:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![erwan22](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@erwan22](https://discuss.elastic.co/u/erwan22)
#### Post date: [April 21, 2021, 2:04pm UTC](https://discuss.elastic.co/t/python-client-send-data-to-elastic-cloud-refused/270853/1 "2021-04-21T14:04:29Z")

</div>

Hello,

I have been sending data to my localhost (elastic 7.12) easily with Python.

I'm trying to do the same with elastic cloud with the following command :

```auto
es = Elasticsearch(
cloud_id='my_cloud_id_from_https://cloud.elastic.co/deployments/my_id',
http_auth=('elastic', 'mypassword'), port=443)

helpers.bulk(es, some_data)

```

I have the following error :

```auto
ConnectionError: ConnectionError(<urllib3.connection.HTTPSConnection object at 0x0000021278455EB0>: Failed to establish a new connection: [WinError 10061] Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée) caused by: NewConnectionError(<urllib3.connection.HTTPSConnection object at 0x0000021278455EB0>: Failed to establish a new connection: [WinError 10061] Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée)

```

Sorry, some sentences are in french but basically, the connexion is refused.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 21, 2021, 3:47pm UTC](https://discuss.elastic.co/t/python-client-send-data-to-elastic-cloud-refused/270853/2 "2021-04-21T15:47:55Z")

</div>

Bonjour Erwan 🙂

If you are using a localhost instance, I don't think you can use `cloud_id` in that case which is specific for an elasticsearch cluster running on cloud.  
And I believe that localhost is the default value for this client so something like the following should work I think:

```auto
es = Elasticsearch(http_auth=('elastic', 'mypassword'))
helpers.bulk(es, some_data)

```

Is you local cluster secured?  
If not, you can run this I think:

```auto
es = Elasticsearch()
helpers.bulk(es, some_data)

```

---

<div class="post-metadata">

### Author: ![erwan22](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@erwan22](https://discuss.elastic.co/u/erwan22)
#### Post date: [April 22, 2021, 9:27am UTC](https://discuss.elastic.co/t/python-client-send-data-to-elastic-cloud-refused/270853/4 "2021-04-22T09:27:09Z")

</div>

Hello,

I found the solution if it can help someone :  
`es = Elasticsearch( cloud_id='cluster-1:my_cluster_id_from_https://cloud.elastic.co/deployments', http_auth=('user', 'password'), port=443 ) helpers.bulk(es, some_data)``

---

<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: [May 20, 2021, 9:28am UTC](https://discuss.elastic.co/t/python-client-send-data-to-elastic-cloud-refused/270853/5 "2021-05-20T09:28:08Z")

</div>

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