Skip to content

Proxy port dropped when it matches the scheme default (regression since 8.21.0) #23681

Closed

Description

@zerotohero3

I did this

curl -v --socks5 127.0.0.1:80 http://example.com/
*   Trying 127.0.0.1:1080...

I expected the following

curl should connect to the SOCKS proxy on port 80, as 8.20.0 and earlier do.

Since 8.21.0, Curl_peer_from_proxy_url() reads the proxy port with CURLU_NO_DEFAULT_PORT. That drops an explicit port whenever it matches the default port of the proxy URL's scheme. A proxy string without a scheme is guessed as http, so :80 is lost even when the proxy is SOCKS. curl then falls back to CURLOPT_PROXYPORT or a default:

  • --socks5 host:80, --socks4 host:80 and --preproxy host:80 connect to 1080
  • CURLOPT_PROXY "http://host:80" with CURLOPT_PROXYPORT 3128 connects to 3128
  • CURLOPT_PROXY "socks5://host:1080" with CURLOPT_PROXYPORT 9999 connects to 9999

The fallback changed too. It is now the scheme's default port, not the documented 1080, so -x host (no port) goes to port 80. CURLOPT_PROXY.md, CURLOPT_PROXYPORT.md and proxy.md still say 1080 (443 for HTTPS proxies).

This came in with bc40e09 (lib: introduce Curl_peer). The code is the same in 8.21.0, 8.22.0 and 8.23.0. I checked the behavior on current master; curl 8.18.0 does what the docs say.

curl/libcurl version

curl 8.23.1-DEV (master, a502385). Affects 8.21.0 and later.

operating system

Linux. Nothing here is OS-specific.

Activity

  1. icing commented on Oct 30, 2026

    @icing
    Contributor

    Fixed in #23682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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