title: connection error while connecting python to elasticsearch
body: <pre><code>from elasticsearch import Elasticsearch
  es = Elasticsearch([{'host': '192.168.7.101', 'port': 9200}])
  es
  res = es.search(index='opm', body = {"query": {"match": {"event_country_name":"Singapore"}}}, request_timeout=30)
  </code></pre>
  
  <p>The code above gives the following error:  </p>
  
  <blockquote>
    <p>ConnectionError: ConnectionError(: Failed to establish a new connection:
    [WinError 10060] A connection attempt failed because the connected
    party did not properly respond after a period of time, or established
    connection failed because connected host has failed to respond) caused
    by: NewConnectionError(: Failed to establish a new connection: [WinError
    10060] A connection attempt failed because the connected party did not
    properly respond after a period of time, or established connection
    failed because connected host has failed to respond)</p>
  </blockquote>
  
  <p>It was working earlier. I don't know what happened and it is now unreachable. I tried to update the pip. Then I downgraded to see if the issue was related to it. Nothing happened. I even tried to uninstall and reinstall the python and also urllib3.</p>
  
  <p>Please help me out.</p>
  
  <p>The full error message is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.017s]
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
      (self._dns_host, self.port), self.timeout, **extra_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
      raise err
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
      sock.connect(sa)
  TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
      response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
      _stacktrace=sys.exc_info()[2])
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
      raise value
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
      chunked=chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
      self.send(msg)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
      self.connect()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
      conn = self._new_conn()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
      self, "Failed to establish a new connection: %s" % e)
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.HTTPConnection object at 0x0000021CBDA8FF28&gt;: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.020s]
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
      (self._dns_host, self.port), self.timeout, **extra_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
      raise err
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
      sock.connect(sa)
  TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
      response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
      _stacktrace=sys.exc_info()[2])
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
      raise value
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
      chunked=chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
      self.send(msg)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
      self.connect()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
      conn = self._new_conn()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
      self, "Failed to establish a new connection: %s" % e)
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.HTTPConnection object at 0x0000021CBDA8FF98&gt;: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.016s]
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
      (self._dns_host, self.port), self.timeout, **extra_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
      raise err
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
      sock.connect(sa)
  TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
      response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
      _stacktrace=sys.exc_info()[2])
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
      raise value
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
      chunked=chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
      self.send(msg)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
      self.connect()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
      conn = self._new_conn()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
      self, "Failed to establish a new connection: %s" % e)
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.HTTPConnection object at 0x0000021CBDAB20B8&gt;: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  GET http://192.168.7.101:9200/opm/_search [status:N/A request:21.022s]
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
      (self._dns_host, self.port), self.timeout, **extra_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
      raise err
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
      sock.connect(sa)
  TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 172, in perform_request
      response = self.pool.urlopen(method, url, body, retries=Retry(False), headers=request_headers, **kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
      _stacktrace=sys.exc_info()[2])
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\util\retry.py", line 343, in increment
      raise six.reraise(type(error), error, _stacktrace)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\packages\six.py", line 686, in reraise
      raise value
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
      chunked=chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connectionpool.py", line 354, in _make_request
      conn.request(method, url, **httplib_request_kw)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1229, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1275, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1224, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 1016, in _send_output
      self.send(msg)
    File "E:\Data Science\pyWork\PyProjects\Program\lib\http\client.py", line 956, in send
      self.connect()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 196, in connect
      conn = self._new_conn()
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
      self, "Failed to establish a new connection: %s" % e)
  urllib3.exceptions.NewConnectionError: &lt;urllib3.connection.HTTPConnection object at 0x0000021CBDAB2160&gt;: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
  Traceback (most recent call last):
  
    File "&lt;ipython-input-7-37571f0445fd&gt;", line 1, in &lt;module&gt;
      res = es.search(index='opm', body = {"query": {"match": {"event_country_name":"Singapore"}}}, request_timeout=30)
  
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\client\utils.py", line 76, in _wrapped
      return func(*args, params=params, **kwargs)
  
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\client\__init__.py", line 660, in search
      doc_type, '_search'), params=params, body=body)
  
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\transport.py", line 318, in perform_request
      status, headers_response, data = connection.perform_request(method, url, params, body, headers=headers, ignore=ignore, timeout=timeout)
  
    File "E:\Data Science\pyWork\PyProjects\Program\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 181, in perform_request
      raise ConnectionError('N/A', str(e), e)
  
  ConnectionError: ConnectionError(&lt;urllib3.connection.HTTPConnection object at 0x0000021CBDAB2160&gt;: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) caused by: NewConnectionError(&lt;urllib3.connection.HTTPConnection object at 0x0000021CBDAB2160&gt;: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)</code></pre>
  </div>
  </div>
  </p>