# Cannot connect to Elasticsearch cluster using cloud\_id

**URL:** <https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203>\
**Category:** Elasticsearch\
**Created:** [October 10, 2022, 10:00am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203 "2022-10-10T10:00:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 10, 2022, 10:00am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/1 "2022-10-10T10:00:00Z")

</div>

Hi All,

I have an issue, I cannot to connect to my Elasticsearch cluster from python client using its cloud\_id.

I am getting following error:

```auto
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\client\utils.py", line 347, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\client\ __init__.py", line 296, in info
    "GET", "/", params=params, headers=headers
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\transport.py", line 417, in perform_request
    self._do_verify_elasticsearch(headers=headers, timeout=timeout)
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\transport.py", line 606, in _do_verify_elasticsearch
    raise error
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\transport.py", line 570, in _do_verify_elasticsearch
    "GET", "/", headers=headers, timeout=timeout
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 291, in perform_request
    self._raise_error(response.status, raw_data)
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\connection\base.py", line 329, in _raise_error
    status_code, error_message, additional_info
elasticsearch.exceptions.TransportError: TransportError(303, '')

```

Please advise.

Thanks & Regards,

Hamid

---

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 10, 2022, 10:20am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/2 "2022-10-10T10:20:18Z")

</div>

After setting log level to DEBUG I can see below message in the log.

`2022-10-10 13:12:01,955 [13056] [_make_request] : https://xxxxxxxx.net:None "GET / HTTP/1.1" 303 0`

It looks that I cannot access to Elasticsearch cluster url while Kibana works fine.

Please advise.

Thanks & Regards,

Hamid

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 10, 2022, 12:31pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/3 "2022-10-10T12:31:55Z")

</div>

Perhaps you can share your code not just the error.

---

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 10, 2022, 12:44pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/4 "2022-10-10T12:44:45Z")

</div>

Hi Stephen,

Thanks for your reply.

I think my code is ok because it is working for others cluster.

Below you can find the function I am using to create elastic connection.

```auto
def get_es_connection(es_args):
    logger.info('Connecting to Elasticsearch Cluster ...')
    logger.debug(es_args)

    es_cloud_id = es_args['cloud_id']
    es_user = es_args['user']
    es_password = es_args['password']

    es = Elasticsearch(
        cloud_id=es_cloud_id,
        http_auth=(es_user, es_password)
    )

    return es

```

I think my issue is with the elasticsearch cluster url because when I tested it on browser I am getting a java error.

Thanks.

---

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 10, 2022, 12:50pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/5 "2022-10-10T12:50:58Z")

</div>

below is the error shown in browser console.

```auto
stateService.js:33 Transition Rejection($id: 0 type: 6, message: The transition errored, detail: {"data":{"type":"com.sksamuel.elastic4s.http.JavaClientExceptionWrapper","message":"java.lang.NullPointerException"},"status":500,"headers":"function(e){if(t||(t=Rt(A)),e){var n=t[Bi(e)];return void 0===n&&(n=null),n}return t}","config":{"method":"GET","transformRequest":"function(A){return!Q(A)||S(A)||m(A)||z(A)?A:q(A)}","transformResponse":"function kt(A,t){if(h(A)","paramSerializer":"function(A){if(!A)return"";var t=[];return g(A,function(A,e){null===A||l(A)||f(A)||(j(A)?M(A,function(A){t.push(IA(e)+"="+IA(Ot(A)))}):t.push(IA(e)+"="+IA(Ot(A))))}),t.join("&")}","jsonpCallbackParam":"callback","url":"./api/user/current","headers":{"Accept":"application/json, text/plain, */*","X-CORTEX-XSRF-TOKEN":"ecef1f91d4ac8692af0bcf3a8e84daf8d8e7dad8-1665406088546-cb3e5845edd11c2dbcd78fb3"}},"statusText":"Internal Server Error","xhrStatus":"complete"})

```

Thanks

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [October 10, 2022, 4:30pm UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/6 "2022-10-10T16:30:22Z")

</div>

Exactly where did you copy the cloud id from and you made sure there were not typos etc?

 ![Screen Shot 2022-10-10 at 8.29.22 AM](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56f9c1c65fceaffc0b5790fe6095e38c6c761816.png)

`2022-10-10 13:12:01,955 [13056] [_make_request] : https://xxxxxxxx.net:None "GET / HTTP/1.1" 303 0`

I don't think any Elastic Cloud URLs end in `.net`. I could be wrong but I don't think so...

---

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 11, 2022, 7:09am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/7 "2022-10-11T07:09:30Z")

</div>

Hi Stephen,

Thank you for your reply. Actually the cloud\_id is correct and the .net is the URL used to access Elasticsearch cluster. Even when I copied Elasticserach endpoint from ECE UI and use it in the browser it is not responding, I am getting an error.

I think the error is due to Elasticsearch not accessible, I dont know why. Kibana is working fine.

Thanks & Best Regards,

Hamid

---

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 11, 2022, 7:15am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/8 "2022-10-11T07:15:35Z")

</div>

I can see below message at the bottom of the browser while trying to access Elasticsearch url.

![image](https://us1.discourse-cdn.com/elastic/original/3X/7/4/74b79284989aa3dcbaf0a297e27879b107c3fe5a.png)

---

<div class="post-metadata">

**Author:** ![h.allaoui](https://avatars.discourse-cdn.com/v4/letter/h/f07891/32.png) [@h.allaoui](https://discuss.elastic.co/u/h.allaoui)\
**Post date:** [October 11, 2022, 7:57am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/9 "2022-10-11T07:57:00Z")

</div>

Hi Stephen,

My issue has been fixed. Actually we are using a load balancer and configuration was missing to access that Elasticsearch endpoint as defined in ECE.

Thanks All.

Hamid

---

<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:** [November 8, 2022, 7:57am UTC](https://discuss.elastic.co/t/cannot-connect-to-elasticsearch-cluster-using-cloud-id/316203/10 "2022-11-08T07:57:30Z")

</div>

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