Skip to content

Mixed proxy and destination ip versions don't connect #21146

@terrancewong

Description

@terrancewong

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions