How to connect to ECE with python?

(weibin.wu) #1


I already whitelist 9243 port to my load test server.
I can do with the following curl
curl -XGET -k

But when I was using python to connect. I download the cert from Cloud UI->platform->Settings and saved as "cloud_certs"
Then use the following code to connect.

es = Elasticsearch(

It gives me

elasticsearch.exceptions.ConnectionError: ConnectionError((<urllib3.connection.VerifiedHTTPSConnection object at 0x7f862617b990>, 'Connection to timed out. (connect timeout=10)')) caused by: ConnectTimeoutError((<urllib3.connection.VerifiedHTTPSConnection object at 0x7f862617b990>, 'Connection to timed out. (connect timeout=10)'))

I tried a lot of trouble shoot but no good news. Whats the correct way to use pythong connect to ECE?

(Uri Cohen) #2

Hi @weibin.wu

Note that the hostname you're using ends with The domain is a "magic" domain name managed by Elastic, that provides wildcard DNS for any IP address. So in your case, will simply resolve to We use this solution to save the need for users to define their own wildcard DNS record while evaluating ECE. In a production setup, you probably don't want to rely on this service, and we recommend that you have your own wildcard DNS name that resolves to one of the ECE proxy hosts or a load balancer that fronts them.
In this specific case, for this to work properly you need to make sure that:

  • The host which runs your Python code has internet access (so it can access
  • The IP adderss resolves from that same host.


(Alex Piggott) #3

Hi @weibin.wu

Can you try connecting over :9200 first? Eg open :9200 in the firewall and connect to first via curl and then with a similar python snippet.

That will take certification issues out the way, and also importantly, if the connection to 9200 fails you can use tcpdump to diagnose what's going on.

(You might also be able to get more information by upping the logging level:

import logging



(weibin.wu) #4

Thats an very impressing DNS magic. Thanks

I checked our server has internet access and can resolve the
Do you have an example of code to connect to ECE with python?

(weibin.wu) #5

Thanks Alex,

That really resolve my problem. Becuase we are using ECE as an internal service. So using port 9200 will facilitate a lot for our work rather than using port 9243.

(system) #6

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