Can't connect to IPv6 Address with Zone ID
See original GitHub issueFrom @alex-fu27 psf/requests#5126:
Requests fails on IPv6 URLs that contain a zone identifier when used with the current urllib3 (1.25).
Expected Result Prior to urllib3 v1.25, I could do this:
import requests requests.get(“http://[fe80::145e:58ff:fec3:4698%enp0s20u1]:8080/”) And it worked as intended.
Actual Result Since I upgraded to urllib 1.25 and requests 2.22, this fails with [Errno -2] Name or service not known, because requests is escaping the % character and trying to access [fe80::145e:58ff:fec3:4698%25enp0s20u1] instead.
Minimum requirements
💵 You can get paid to complete this issue! Please read the docs for more information.
- Read https://datatracker.ietf.org/doc/html/rfc4007 and https://datatracker.ietf.org/doc/html/rfc6874 to understand the feature
- Research and document why urllib3<1.25 worked while urllib3>=1.25 doesn’t work in this issue
- Figure out the best percent encoding strategy for Python across all platforms (Linux, macOS, and Windows). You can reach out to maintainers with a script to test this on their own machine if you don’t have access to a certain platform. A valid outcome of this is “we shouldn’t modify the Zone ID separator” but let’s test instead of assume!
- Implement the feature to forward Zone ID from the authority to the
socket.create_connectioncall. - Add test cases that can run on CI (might have to use mocks of
urllib3.util.connection.create_connection?) but should have the ability to run a live test when available (figure out how to detect this situation at least on Linux)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Can't specify ZoneID when using link-local IPv6 address.
1. Have a web site available through link-local IPv6 connectivity. 2. Try specifying the IPv6 link-local scope ID in the URL.
Read more >What's that % sign after ipconfig IPv6 address?
To resolve this issue there is Zone ID added to every NIC. This is the mysterious number after the % sign in the...
Read more >Part 7: Zone ID and unique local IPv6 unicast addresses
The zone ID is used to distinguish ambiguous link-local and site-local addresses. Unique local IPv6 unicast addresses are another way to ...
Read more >Understanding IPv6 Link-local Addresses Zone IDs - TechGenix
Zone IDs can be used with other types of addresses but it is recommended to always use the zone ID when connecting to...
Read more >Why don't we have zone id (like in IPv6 addresses after ...
Because every IPv6 interface has the same network, so you need the Zone ID to determine which interface is meant when sending to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m working on resolving this issue and another issue related to IPv6 Zone IDs.
This issue has been closed in https://github.com/urllib3/urllib3/pull/2629 and and #2635. Thanks @delroth! I look forward to seeing your invoice to collect the bounty.