URLError: <urlopen error [Errno 11001] getaddrinfo failed>

Peter J. Holzer hjp-python at hjp.at
Sat Feb 12 15:25:34 EST 2022


On 2022-02-12 20:15:43 +0000, Shaozhong SHI wrote:
> The following is used in a loop to get response code for each url.
> 
> print (urllib.request.urlopen(url).getcode())
> 
> However, error message says: URLError: <urlopen error [Errno 11001]
> getaddrinfo failed>
> 
> Python 3.6.5 is being used to test whether url is live or not.
> 
> Can anyone shed light on this?

getaddrinfo is the function that resolves a domain name into an IP
address. If that fails, either the domain name doesn't exist or you have
a problem with your DNS setup.

Things to test:

* Can you resolve the domain name to an address (try «nslookup» or
  «host» or «dig» depending on your OS)?
* Can you access the whole URL with a different tool like «wget» or
  «curl»?

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20220212/67f0aca0/attachment.sig>


More information about the Python-list mailing list