Repository navigation
Closed
Labels
Description
I did this
| V proxy / target > | IPv4 | IPv6 |
|---|---|---|
| IPv4 | Y | N |
| IPv6 | N | Y |
% curl -4 --proxy http://127.0.0.1:1080 -o /dev/null http://www.google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 79445 0 79445 0 0 49515 0 00:01 49534
% curl -6 --proxy='http://[::1]:1080' -o /dev/null http://www.google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 79271 0 79271 0 0 50789 0 00:01 2973
% curl -6 --proxy http://127.0.0.1:1080 -o /dev/null http://www.google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 0
curl: (7) Failed to connect to www.google.com port 80 via 127.0.0.1 after 0 ms: Could not connect to server
% curl -4 --proxy='http://[::1]:1080' -o /dev/null http://www.google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 0
curl: (7) Failed to connect to www.google.com port 80 via ::1 after 0 ms: Could not connect to server
So, if the proxy is configured in ~/.curlrc, It almost have 50% chance to fail, if the wen site has IP both v4 and v6.
I can confirm my proxy works all 4 ways, tested using firefox.
I expected the following
I expect both version of proxy can work with both version of IP,
curl/libcurl version
% curl --version
curl 8.19.0 (x86_64-pc-linux-gnu) libcurl/8.19.0 OpenSSL/3.5.5 zlib/1.3.1 brotli/1.2.0 zstd/1.5.7 libidn2/2.3.8 libpsl/0.21.2 libssh2/1.11.1 nghttp2/1.68.0 ngtcp2/1.21.0 nghttp3/1.15.0 librtmp/2.3 mit-krb5/1.22.1 OpenLDAP/2.6.10
Release-Date: 2026-03-11, security patched: 8.19.0-1
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt mqtts pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
operating system
Linux 6.19.6+deb14+1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.19.6-2 (2026-03-12) x86_64 GNU/Linux
Activity
bagder commentedon Mar 29, 2026
But Firefox has no -4 / -6 options so it's not really the same thing you've tested.
For example, just to understand what we are talking about:
What exactly do you expect this command line to do?
-6is documented tojay commentedon Apr 12, 2026
Ref: https://curl.se/docs/manpage.html#--ipv4
Ref: https://curl.se/docs/manpage.html#--ipv6
I think the reporter has a point. He's saying basically this:
-4, --ipv4 doc says: "Request only IPv4 addresses when resolving hostnames, and not for example any IPv6."
-6, --ipv6 doc says: "Request only IPv6 addresses when resolving hostnames, and not for example any IPv4."
Furthermore curl -4 and -6 map internally to libcurl CURL_IPRESOLVE_V4 and CURL_IPRESOLVE_V6, respectively, and that doc says: "If the URL provided for a transfer contains a numerical IP version as a host name, this option does not override or prohibit libcurl from using that IP version."
I think it's reasonable to assume that -4 and -6 do not stop connections to the opposite type of IP address if that IP address is user specified (ie it is not resolved). As the reporter said this issue can make it hard to use --proxy with an IP address in the curlrc
icing commentedon Apr 13, 2026
Makes sense to me.
resolve user supplied ip addresses
icing commentedon Apr 13, 2026
My proposal on fixing this: #21295.
@terrancewong care to test the PR to see if it does what you want? Thanks!
hostip: resolve user supplied ip addresses
hostip: resolve user supplied ip addresses