I created an app in python which uses the module requests. When I run it, it works correctly, but when I snap it, it fails with a ConnectionError.
I created a minimal snap app to reproduce the error.
The error is the following:
Traceback (most recent call last):
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/snap/requests-error/x1/usr/lib/python3.6/socket.py", line 743, 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 "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/snap/requests-error/x1/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connection.py", line 166, in connect
conn = self._new_conn()
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9b132a94a8>: 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 "/snap/requests-error/x1/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/snap/requests-error/x1/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='google.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b132a94a8>: 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 "/snap/requests-error/x1/bin/requests-error.py", line 5, in <module>
requests.get('http://google.com')
File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/sessions.py", line 502, in request
resp = self.send(prep, **send_kwargs)
File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/sessions.py", line 612, in send
r = adapter.send(request, **kwargs)
File "/snap/requests-error/x1/lib/python3.6/site-packages/requests/adapters.py", line 504, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='google.com', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b132a94a8>: Failed to establish a new connection: [Errno -2] Name or service not known',))
ProblemType: Bug
DistroRelease: Ubuntu 17.10
Package: snapd 2.26.10+17.10
ProcVersionSignature: Ubuntu 4.11.0-10.15-generic 4.11.8
Uname: Linux 4.11.0-10-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia_drm nvidia_modeset nvidia
ApportVersion: 2.20.6-0ubuntu4
Architecture: amd64
CurrentDesktop: GNOME
Date: Thu Jul 27 20:48:13 2017
InstallationDate: Installed on 2015-03-21 (859 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha amd64 (20150321)
SourcePackage: snapd
UpgradeStatus: Upgraded to artful on 2017-07-18 (9 days ago)
you syslog might be helpful too (to see possible apparmor denials)