Python Requests HTTPConnectionPool and Max retries exceeded with url
So the Max retries exceeded with url: ...
bit can be vastly confusing. In all likelihood (since you mention that this works using localhost) that this is an application that you're deploying somewhere. This would also explain why the host name is andes-1-47
and not something most would expect (e.g., example.com
). My best guess is that you need to either use the IP address for andes-1-47
(e.g., 192.168.0.255
) or your linux cluster doesn't know how to resolve andes-1-47
and you should add it to your /etc/hosts
file (i.e., adding the line: 192.168.0.255 andes-1-47
).
If you want to see if your linux cluster can resolve the name you can always use this script:
import socket
socket.create_connection(('andes-1-47', 8181), timeout=2)
This will timeout in 2 seconds if you cannot resolve the hostname. (You can remove the timeout but it may take a lot longer to determine if the hostname is reachable that way.)
in the urlopen
call, try setting retries=False
or retries=1
to see the difference. The default is 3
, which sounds quite reasonable.
http://urllib3.readthedocs.org/en/latest/pools.html#urllib3.connectionpool.HTTPConnectionPool.urlopen