diff --git a/news/5380.bugfix b/news/5380.bugfix new file mode 100644 index 000000000..7e4d20256 --- /dev/null +++ b/news/5380.bugfix @@ -0,0 +1 @@ +Raise user friendly errors on network failures diff --git a/src/pip/_internal/network/utils.py b/src/pip/_internal/network/utils.py index 134848ae5..3c8e9ab83 100644 --- a/src/pip/_internal/network/utils.py +++ b/src/pip/_internal/network/utils.py @@ -1,6 +1,7 @@ from typing import Dict, Generator from pip._vendor.requests.models import CONTENT_CHUNK_SIZE, Response +from pip._vendor.urllib3.exceptions import NewConnectionError, ReadTimeoutError from pip._internal.exceptions import NetworkConnectionError @@ -94,3 +95,8 @@ def response_chunks( if not chunk: break yield chunk + except (NewConnectionError, ReadTimeoutError) as exc: + raise NetworkConnectionError( + "Failed to get address for host! Check your network connectivity " + "and DNS settings.\nDetails: {}".format(exc) + )