Elasticsearch-py: urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9e5db5d208>: Failed to establish a new connection: [Errno 113] No route to host

Created on 10 Aug 2018  Â·  17Comments  Â·  Source: elastic/elasticsearch-py

I often have this error, but script works :

GET http://x.x.x.x:9200/_nodes/_all/http [status:N/A request:2.992s]
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 79, in create_connection
raise err
File "/usr/lib/python3.6/site-packages/urllib3/util/connection.py", line 69, in create_connection
sock.connect(sa)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/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 "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 343, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3.6/site-packages/urllib3/packages/six.py", line 686, in reraise
raise value
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, *
httplib_request_kw)
File "/usr/lib64/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib64/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib64/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib64/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib64/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 196, in connect
conn = self._new_conn()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 113] No route to host

Most helpful comment

Firewall block because too many connection, change rule of block

All 17 comments

It sounds like there might be some problem in the connection between your python program and your Elasticsearch cluster.

Unfortunately I can't offer any advice here because there's not enough information.

How many nodes are in your cluster. Do you have them sitting behind a proxy or not? are you using x-pack or not? are you using a hosted service or hosting it your self.

There's a lot of factors here going on that can cause HTTP connection errors.

Any more info would be helpful.

thanks

More info :
3 nodes : 3 VM 8cpu 20go config script with these 3 nodes
No proxy
Not xpack
Hosting myself
No problem when i use rest with EL.

Laurent

Le ven. 10 août 2018 à 17:59, Nick Lang notifications@github.com a écrit :

It sounds like there might be some problem in the connection between your
python program and your Elasticsearch cluster.

Unfortunately I can't offer any advice here because there's not enough
information.

How many nodes are in your cluster. Do you have them sitting behind a
proxy or not? are you using x-pack or not? are you using a hosted service
or hosting it your self.

There's a lot of factors here going on that can cause HTTP connection
errors.

Any more info would be helpful.

thanks

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/elastic/elasticsearch-py/issues/836#issuecomment-412127424,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIXnW-WsQQoeCYYqGwR0ymcB5U4QnQX2ks5uPa3ngaJpZM4V4Fqp
.

@laurentvv thanks for that. This is helpful.

My next question is you say you have 3 nodes, 3 VM's. Where are those VM's running? Are they all on one computer? On 3 computers? In a data center? On your desk?

On a related note:

If you use curl instead of the python client. Do you experience similar errors?

Datacenter
No error with curl
These error don't block my script.
I have a result i don't understand why i have these error

Le ven. 10 août 2018 à 18:54, Nick Lang notifications@github.com a écrit :

On a related note:

If you use curl instead of the python client. Do you experience similar
errors?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/elastic/elasticsearch-py/issues/836#issuecomment-412142138,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIXnWxfevOrz88ouKcI-iW0rHMOI_Dwsks5uPbrJgaJpZM4V4Fqp
.

the error you're getting is a result of a network connection or firewall rule or something.
It is actually not an error related to

  1. Elasticsearch
  2. Elasticsearch-py (this library)

This error is coming from urllib3. And the reason you're getting this error is because python can not make a connection to the HTTP host it's trying to connect to.

If we take out Elasticsearch and Elasticsearch-py. This error happens because a python process using URLlib3 can not connect to a networked host.

This is why I asked all the questions, because somewhere you have a network configuration that's causing the python process to not be able to connect to a host in your cluster. It could be related to anything from the VM firewall rules, the host firewall rules, the data center firewall rules, routers, etc..

closing this issue since there is no new information. Please feel free to reopen with additional data. Thank you!

@laurentvv did you solve this issue?

Yes firewall problem, its ok now. thks

How did you solve this issue? Is this really a firewall issue. I too face the same issue. Getting success in curl and failed in urllib3 HTTP connection.

Firewall block because too many connection, change rule of block

How you blocked that can you explain?

Hello, I am also experimenting the same issue. Would be great to get some help.
Many thanks
Marie-Laure

Hello, I am also experimenting with the same issue. Would be great to get some help.
Many thanks

Same issue here. I'm using Lubuntu 18. How can I change the firewall rules? @laurentvv

This happens when you have parallel competition for the connection. Try to finish opened connections from appium and run it again.

Hi everyone. i am trying to solve the same problem. i closed the firewall but it didnt work..i am using windows

Was this page helpful?
0 / 5 - 0 ratings