Skip to content

Can't connect to IPv6 addresses with zone ID #5126

@alex-fu27

Description

@alex-fu27

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.

Reproduction Steps

Install requests 2.22 or 2.21 and urllib 1.25 and try the two lines from "Expected Result", replacing the IP, zone ID and port. It might be a little tricky to reproduce if you do not have a device with a link-local address at hand.

System Information

{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.7.3"
  },
  "platform": {
    "release": "5.1.14-arch1-1-ARCH",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.22.0"
  },
  "system_ssl": {
    "version": "1010103f"
  },
  "urllib3": {
    "version": "1.25.3"
  },
  "using_pyopenssl": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions