Home > Back-end >  requests.exceptions.ConnectionError (works in local machine, but not in the virtual machine)
requests.exceptions.ConnectionError (works in local machine, but not in the virtual machine)

Time:07-24

I'm working on a request through the Rest API as follows:

url = "https://api.goldstandard.org/credits"
JSONContent = requests.get(url).json()

For some reason (it has been working well for the past months), the code in the virtual machine returns the following error:

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.goldstandard.org', port=443): Max retries exceeded with url: /credits (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002877795F700>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

I tried the same code on my local machine and it worked, which I guess is something to do with some verifications. It would be highly appreciated if any one could give some advice here.


(added) I found that this should be related to the DNS setting (or cache) of my virtual machine (GCP). When I visit https://api.goldstandard.com/, it say as follows:

Check if there is a typo in api.goldstandard.com.
If spelling is correct, try running Windows Network Diagnostics.
DNS_PROBE_FINISHED_NXDOMAIN

I've already flushed DNS in this machine. So other advice would be appreciated.

CodePudding user response:

Fixed by the following setting changes (https://kinsta.com/knowledgebase/dns_probe_finished_nxdomain/):

Make a note of any existing settings in case you need to revert back. Click “Use the following DNS server addresses.” Enter the following, or replace the existing with these:

For IPv4: 1.1.1.1 and 1.0.0.1 For IPv6: 2606:4700:4700::1111 and 2606:4700:4700::1001

  • Related