Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to sole the problem of "ConnectionRefusedError: [Errno 111] Connection refused" #64

Open
yibingchen2023 opened this issue Dec 14, 2024 · 5 comments

Comments

@yibingchen2023
Copy link

When I run the code, I can't connect the url " /records/14445620/files/release_v1.5.0.zip?download=1". How to solve this problem? Can I download the corresponding files using other ways?

@FabianIsensee
Copy link
Member

Hey,
I just verified that this works. Can you please try again and post the error message?
Best,
Fabian

@yibingchen2023
Copy link
Author

Thanks, and the error message is as follows (I am in China):

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 775, in urlopen
self._prepare_proxy(conn)
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1044, in _prepare_proxy
conn.connect()
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 730, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 909, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/ssl
.py", line 469, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/ssl
.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/ssl.py", line 1104, in _create
self.do_handshake()
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/ssl.py", line 1382, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/retry.py", line 474, in increment
raise reraise(type(error), error, _stacktrace)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/util.py", line 38, in reraise
raise value.with_traceback(tb)
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 775, in urlopen
self._prepare_proxy(conn)
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1044, in _prepare_proxy
conn.connect()
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 730, in connect
sock_and_verified = _ssl_wrap_socket_and_match_hostname(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 909, in ssl_wrap_socket_and_match_hostname
ssl_sock = ssl_wrap_socket(
^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/ssl
.py", line 469, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls, server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/ssl
.py", line 513, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/ssl.py", line 517, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/ssl.py", line 1104, in _create
self.do_handshake()
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/ssl.py", line 1382, in do_handshake
self._sslobj.do_handshake()
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/bin/hd-bet", line 8, in
sys.exit(main())
^^^^^^
File "/home/cyb/cyb_sda2/isles/ISLES-2022_segment_yes/code/3DUnetCNN/examples/brain_extraction/comparison_methods/HD-BET/HD_BET/entry_point.py", line 45, in main
maybe_download_parameters()
File "/home/cyb/cyb_sda2/isles/ISLES-2022_segment_yes/code/3DUnetCNN/examples/brain_extraction/comparison_methods/HD-BET/HD_BET/checkpoint_download.py", line 30, in maybe_download_parameters
fname = download_file(ZENODO_DOWNLOAD_URL, join(folder_with_parameter_files, os.pardir, 'tmp_download.zip'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/cyb_sda2/isles/ISLES-2022_segment_yes/code/3DUnetCNN/examples/brain_extraction/comparison_methods/HD-BET/HD_BET/checkpoint_download.py", line 19, in download_file
with requests.get(url, stream=True, timeout=100) as r:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/adapters.py", line 682, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

@yibingchen2023
Copy link
Author

The above is the error message that I used a proxy software to access the Internet from foreign servers. I'm in China. The below error message is the error message that I didn't use the proxy software.

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 199, in _new_conn
sock = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/connection.py", line 85, in create_connection
raise err
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/connection.py", line 73, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 775, in urlopen
self._prepare_proxy(conn)
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1044, in _prepare_proxy
conn.connect()
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 693, in connect
self.sock = sock = self._new_conn()
^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connection.py", line 214, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f826471ab10>: Failed to establish a new connection: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

urllib3.exceptions.ProxyError: ('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f826471ab10>: Failed to establish a new connection: [Errno 111] Connection refused'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/connectionpool.py", line 843, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/urllib3/util/retry.py", line 519, in increment
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='zenodo.org', port=443): Max retries exceeded with url: /records/14445620/files/release_v1.5.0.zip?download=1 (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f826471ab10>: Failed to establish a new connection: [Errno 111] Connection refused')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/cyb/anaconda3/envs/hdbet/bin/hd-bet", line 8, in
sys.exit(main())
^^^^^^
File "/home/cyb/cyb_sda2/isles/ISLES-2022_segment_yes/code/3DUnetCNN/examples/brain_extraction/comparison_methods/HD-BET/HD_BET/entry_point.py", line 45, in main
maybe_download_parameters()
File "/home/cyb/cyb_sda2/isles/ISLES-2022_segment_yes/code/3DUnetCNN/examples/brain_extraction/comparison_methods/HD-BET/HD_BET/checkpoint_download.py", line 30, in maybe_download_parameters
fname = download_file(ZENODO_DOWNLOAD_URL, join(folder_with_parameter_files, os.pardir, 'tmp_download.zip'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/cyb_sda2/isles/ISLES-2022_segment_yes/code/3DUnetCNN/examples/brain_extraction/comparison_methods/HD-BET/HD_BET/checkpoint_download.py", line 19, in download_file
with requests.get(url, stream=True, timeout=100) as r:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/api.py", line 73, in get
return request("get", url, params=params, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cyb/anaconda3/envs/hdbet/lib/python3.11/site-packages/requests/adapters.py", line 694, in send
raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='zenodo.org', port=443): Max retries exceeded with url: /records/14445620/files/release_v1.5.0.zip?download=1 (Caused by ProxyError('Unable to connect to proxy', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f826471ab10>: Failed to establish a new connection: [Errno 111] Connection refused')))

@yibingchen2023
Copy link
Author

Thank you very much. I have good news for you. When I used proxy software with the foreign servers and ran the coding again, it worked without any errors!

@FabianIsensee
Copy link
Member

Great! Happy it works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants