# Meeting a ConnectionError when python connect the elasticsearch?

**URL:** <https://discuss.elastic.co/t/meeting-a-connectionerror-when-python-connect-the-elasticsearch/215621>\
**Category:** Elasticsearch\
**Created:** [January 19, 2020, 12:06pm UTC](https://discuss.elastic.co/t/meeting-a-connectionerror-when-python-connect-the-elasticsearch/215621 "2020-01-19T12:06:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunnut](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@sunnut](https://discuss.elastic.co/u/sunnut)\
**Post date:** [January 19, 2020, 12:06pm UTC](https://discuss.elastic.co/t/meeting-a-connectionerror-when-python-connect-the-elasticsearch/215621/1 "2020-01-19T12:06:14Z")

</div>

Code:  
from elasticsearch import Elasticsearch  
from ssl import create\_default\_context

context = create\_default\_context(cafile="XXX.pem")  
es = Elasticsearch("[https://IP:9200](https://IP:9200)", ssl\_context=context, http\_auth=('username','password'))  
es.info()

ERROR:  
/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/connection/http\_urllib3.py:148: UserWarning: When using `ssl_context`, all other SSL related kwargs are ignored  
"When using `ssl_context`, all other SSL related kwargs are ignored"  
Traceback (most recent call last):  
File "es.py", line 6, in   
es.info()  
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 84, in \_wrapped  
return func(\*args, params=params, \*\*kwargs)  
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/client/ **init**.py", line 291, in info  
return self.transport.perform\_request("GET", "/", params=params)  
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/transport.py", line 358, in perform\_request  
timeout=timeout,  
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/connection/http\_urllib3.py", line 254, in perform\_request  
raise ConnectionError("N/A", str(e), e)  
elasticsearch.exceptions.ConnectionError: ConnectionError(check\_hostname requires server\_hostname) caused by: ValueError(check\_hostname requires server\_hostname)

---

<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:** [February 16, 2020, 12:08pm UTC](https://discuss.elastic.co/t/meeting-a-connectionerror-when-python-connect-the-elasticsearch/215621/2 "2020-02-16T12:08:02Z")

</div>

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