pyicloud icon indicating copy to clipboard operation
pyicloud copied to clipboard

Failed to establish a new connection: [Errno -2] Name or service not known',))

Open Suncatcher opened this issue 6 years ago • 3 comments
trafficstars

I get this while creating API object

api = PyiCloudService('user', 'pass')

Here is the traceback

Traceback (most recent call last):
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn
	(self._dns_host, self.port), self.timeout, **extra_kw)
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection
	for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
	for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
	chunked=chunked)
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 343, in _make_request
	self._validate_conn(conn)
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 839, in _validate_conn
	conn.connect()
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connection.py", line 301, in connect
	conn = self._new_conn()
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connection.py", line 168, in _new_conn
	self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f4a326bd390>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ussa/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
	timeout=timeout
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
	_stacktrace=sys.exc_info()[2])
  File "/home/ussa/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
	raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='p28-photosws.icloud.com', port=443): Max retries exceeded with url: /ph/startup?clientBuildNumber=14E45&clientId=72D08A66-3E3E-11E9-8D1E-00155D016506&dsid=16095247245 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f4a326bd390>: Failed to establish a new connection: [Errno -2] Name or service not known',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "icloud.py", line 34, in <module>
	object_methods = [method_name for method_name in dir(api)
  File "icloud.py", line 35, in <listcomp>
	if callable(getattr(api, method_name))]
  File "/home/ussa/.local/lib/python3.6/site-packages/pyicloud/base.py", line 304, in photos
	self.params
  File "/home/ussa/.local/lib/python3.6/site-packages/pyicloud/services/photos.py", line 30, in __init__
	params=self.params
  File "/home/ussa/.local/lib/python3.6/site-packages/requests/sessions.py", line 546, in get
	return self.request('GET', url, **kwargs)
  File "/home/ussa/.local/lib/python3.6/site-packages/pyicloud/base.py", line 67, in request
	response = super(PyiCloudSession, self).request(*args, **kwargs)
  File "/home/ussa/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
	resp = self.send(prep, **send_kwargs)
  File "/home/ussa/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
	r = adapter.send(request, **kwargs)
  File "/home/ussa/.local/lib/python3.6/site-packages/requests/adapters.py", line 516, in send
	raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='p28-photosws.icloud.com', port=443): Max retries exceeded with url: /ph/startup?clientBuildNumber=14E45&clientId=72D08A66-3E3E-11E9-8D1E-00155D016506&dsid=16095247245 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f4a326bd390>: Failed to establish a new connection: [Errno -2] Name or service not known',))

Connectivity exists!

Suncatcher avatar Mar 04 '19 05:03 Suncatcher

Hi @Suncatcher !

Is it happening all the time ?

May you think with less fetch frequency it will fix this ?

Thanks.

Quentame avatar Mar 20 '20 22:03 Quentame

I will try again and report back. I haven't used the script for a long time

Suncatcher avatar Mar 23 '20 08:03 Suncatcher

I'm a little late to the part but for anyone who found this page via google search, see if the address resolves to an ip address successfully. In my case, my DNS was having problems which prevented me from accessing 'oauth.google.com' with near the same stack trace as seen here for 'p28-photosws.icloud.com'

JosephCW avatar Feb 03 '21 20:02 JosephCW