Python: urllib3 Library, unable to make requests. Error: urllib3.exceptions.MaxRetryError:
I am new to Python and experiencing issues with the urllib3 library when running on a linux environment. The problem is that the library is unable to make GET requests to any URL's and the requests were tested with other libraries that do similar stuff. The error that I am getting is
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='google.com', port=443): Max retries exceeded with url: / (Caused by ConnectTimeoutError(\<urllib3.connection.HTTPSConnection object at 0x7f43c27f6cd0\>, 'Connection to google.com timed out. (connect timeout=3)'))
As mentioned before, using any other package such as requests or wget performs the request well. Using a PoolManager instead or changing the retry configs will just keep the script running indefinitely.
The code:
import urllib3
try:
response = urllib3.request('GET', 'https://google.com')
if response.status == 200:
print(response.data)
else:
print(response.status)
except Exception as e:
print(e)
Comments
Post a Comment