0

I am using elastic search python client. When I pass sniffing parameters in client, it returns ConnectionRefused error for subsequent calls. Weird thing is it calls get all nodes from localhost which I think can be the issue. Please let me know what am I missing?

Code:

elastic_search_client = elasticsearch.Elasticsearch(['host1:port', 'host2:port'],
                                                    sniff_on_start=True,
                                                    sniff_on_connection_fail=True,
                                                    sniffer_timeout=60)

Stack Trace:

  GET http://127.0.0.1:9200/ [status:N/A request:0.001s] Traceback (most recent call last):   File "/env/lib/python3.7/site-packages/urllib3/connection.py", line 160, in
_new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw   File "/env/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err   File "/env/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "/env/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 229, in perform_request
    method, url, body, retries=Retry(False), headers=request_headers, **kw   File "/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 725, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]   File "/env/lib/python3.7/site-packages/urllib3/util/retry.py", line 379, in increment
    raise six.reraise(type(error), error, _stacktrace)   File "/env/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value   File "/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,   File "/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1298, in
_send_request
    self.endheaders(body, encode_chunked=encode_chunked)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)   File "/opt/python3.7/lib/python3.7/http/client.py", line 1026, in
_send_output
    self.send(msg)   File "/opt/python3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()   File "/env/lib/python3.7/site-packages/urllib3/connection.py", line 187, in connect
    conn = self._new_conn()   File "/env/lib/python3.7/site-packages/urllib3/connection.py", line 172, in
_new_conn
    self, "Failed to establish a new connection: %s" % e urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x3e6d58342c10>: Failed to establish a new connection: [Errno 111] Connection refused
summercostanza
  • 285
  • 1
  • 2
  • 12

1 Answers1

0

The network.host value needs to be changed to node's ip than localhost in elasticsearch.yml

summercostanza
  • 285
  • 1
  • 2
  • 12