Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Requests HTTPConnectionPool and Max retries exceeded with url

On a Linux cluster, I get this error with Requests:

ConnectionError: HTTPConnectionPool(host='andes-1-47', port=8181): Max retries exceeded with url: /jammy/api/v1 (Caused by : '')

What does this error mean? Is it a Requests problem or is it on the host, and what is the solution?

By the way, the program works successfully on both Windows and Linux standalone machines with localhost.

like image 670
Henry Thornton Avatar asked Jun 04 '14 18:06

Henry Thornton


2 Answers

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.)

like image 122
Ian Stapleton Cordasco Avatar answered Nov 09 '22 07:11

Ian Stapleton Cordasco


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

like image 32
johntellsall Avatar answered Nov 09 '22 07:11

johntellsall