Cannot connect to Elasticsearch cluster using cloud_id

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:

  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\client\", 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\", line 296, in info
    "GET", "/", params=params, headers=headers
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\", 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\", line 606, in _do_verify_elasticsearch
    raise error
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\", line 570, in _do_verify_elasticsearch
    "GET", "/", headers=headers, timeout=timeout
  File "D:\Data\Hamid\Workspace\Python\MyTools\venv\lib\site-packages\elasticsearch\connection\", 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\", line 329, in _raise_error
    status_code, error_message, additional_info
elasticsearch.exceptions.TransportError: TransportError(303, '')

Please advise.

Thanks & Regards,


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

2022-10-10 13:12:01,955 [13056] [_make_request] : "GET / HTTP/1.1" 303 0

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

Please advise.

Thanks & Regards,


Perhaps you can share your code not just the error.

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.

def get_es_connection(es_args):'Connecting to Elasticsearch Cluster ...')

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

    es = Elasticsearch(
        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.


below is the error shown in browser console.

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"})


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

2022-10-10 13:12:01,955 [13056] [_make_request] : "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...

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,


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


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.


1 Like

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