Best way to check if there is internet?

Chris Angelico rosuav at gmail.com
Tue Feb 22 13:47:22 EST 2022


On Wed, 23 Feb 2022 at 05:38, Avi Gross via Python-list
<python-list at python.org> wrote:
> It sounds to me like your main issue is not whether the internet is up right now but whether the user has an internet connection. If they run the program on a laptop at home or work then they may well be connected, but sitting in their car in some parking lot, may well not be.
>

Very seldom, a computer actually has *no* network connection. Much
more often, you have a network connection, but it's not very useful.
For example, you might have full network connectivity... but only on
localhost. Or you might be on a LAN, and fully able to access its
resources, but your uplink to the rest of the internet is down. Or
maybe you're a server inside Facebook, and the rest of the internet is
slowly getting disconnected from you. Do you have an internet
connection? Do you have what you need?

*There is no way* to answer the question of whether you have internet
access, other than to try the exact thing you want to do, and see if
it fails. People who think that there's a binary state of "have
internet" // "do not have internet" have clearly never worked in
networking....

(No, I've never accidentally misconfigured a network so that we had
full access to everything *except* the local network. Why do you ask?
Anyway, I fixed it within a few minutes.)

ChrisA


More information about the Python-list mailing list