Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

4,698 views
Skip to first unread message

Shaozhong SHI

unread,
Feb 12, 2022, 3:17:07 PM2/12/22
to
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?

Regards,

David

Peter J. Holzer

unread,
Feb 12, 2022, 3:26:53 PM2/12/22
to
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.
|_|_) | |
| | | h...@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
signature.asc

Chris Angelico

unread,
Feb 12, 2022, 3:27:09 PM2/12/22
to
On Sun, 13 Feb 2022 at 07:17, Shaozhong SHI <shisha...@gmail.com> 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?
>

What that's saying is that it couldn't look up the domain name to get
the corresponding address. Most likely, that means you either don't
have DNS available, or the DNS server said that it couldn't find that
server. (Whether that's true or not. It's always possible for the DNS
server to be wrong.) So, if you can fairly safely assume that you have
a fully-functioning internet connection (for instance, if other URLs
can be fetched successfully), the most reasonable interpretation of
this is that the URL is, in some way, broken.

I suspect that errno 11001 is a Winsock error, in which case it would
mean "Host not found". On my Linux system, I get a chained exception
that says "Name or service not found". Most likely, you can find this
information further up in the traceback.

ChrisA

Gisle Vanem

unread,
Feb 13, 2022, 2:47:03 AM2/13/22
to
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]

11001 == WSAHOST_NOT_FOUND.

Look in any 'winsock.h' header:
#define WSAHOST_NOT_FOUND (WSABASEERR+1001)

--
--gv
0 new messages