I have an API running inside of a Docker container, which I build using docker-compose up --build. Inside of my API code, I need to make a call to an https endpoint online. When attempting to make this request, I am seeing the following error:
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //your-site.com (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7fc40e584f90>: Failed to resolve 'https' ([Errno -3] Temporary failure in name resolution)"))
The same code works outside of the container on my local machine.
This looks wrong: https is not a host, it’s a protocol, and //your-site.com is not an url, as it misses the protocol.
It’s a problem on the python level, not on the container level. You need to fix it in your code.
Hi there, thanks for the note @meyay . I blocked out the specific site for this post – but can assure there is a proper url there in my actual error message and code.
I also have run this code locally (not in a Docker container) with success – so am confident it’s not the code/python. Have tried with other request libraries as well, with same results.