-
-
Notifications
You must be signed in to change notification settings - Fork 831
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
ConnectError: [Errno -2] Name or service not known when URL contains IPv6 #1311
Comments
To my eye it looks like the problem is with the brackets in the URL - they are never stripped Quick fix that I am using at the moment - modification of @property
def host(self) -> str:
"""
The URL host as a string.
Always normlized to lowercase, IDNA encoded
with square brackets stripped from IPv6 host.
Examples:
url = httpx.URL("http://www.EXAMPLE.org")
assert url.host == "www.example.org"
url = httpx.URL("http://中国.icom.museum")
assert url.host == "xn--fiqs8s.icom.museum"
url = httpx.URL("http://[2001:db8:1::242:ac11:2]:5000")
assert url.host = "2001:db8:1::242:ac11:2"
"""
return (self._uri_reference.host or "").lstrip('[').rstrip(']') I do not know however if it is the best place to strip those brackets - let me know what you think. |
Interesting, yup. I guess our options here are to either strip at the Of those I'm minded to strip them at So, what do we think of the following?...
|
I have the same issue and received the following message: The above exception was the direct cause of the following exception: Traceback (most recent call last): |
Describe the bug
When trying to connect to HTTP or HTTP/2 server using URL containing IPv6 address
httpx.ConnectError: [Errno -2] Name or service not known
exception is raised.To reproduce
Run some http server.
In my case it is a Docker container with IPv6 enabled, so for example:
To get IPs of the container:
docker inspect serv --format '{{ .NetworkSettings.GlobalIPv6Address }} {{ .NetworkSettings.IPAddress }}'
Run below code (after adjusting URLs to match IPsextracted from
docker inspect
Expected behavior
Response is returned
Actual behavior
httpx.ConnectError: [Errno -2] Name or service not known
exception is raisedDebugging material
Output from above snippet:
Environment
Additional context
The text was updated successfully, but these errors were encountered: