siyuan-note/siyuan · error

SOCKS5 proxy does not support context dialing

Error message

SOCKS5 proxy does not support context dialing

What it means

When a SOCKS5 proxy is configured, the transport builds a golang.org/x/net/proxy SOCKS5 dialer and asserts it also implements ContextDialer so the request context (timeouts, cancellation) can be honored. If the returned dialer does not, the tunnel cannot be created safely and fails with this error. In practice this only occurs if golangProxy.SOCKS5 returns a non-standard implementation.

Solutions

  1. Update golang.org/x/net to a current version (SOCKS5 dialer implements ContextDialer in all recent releases)
  2. Check go.mod for a replace/pin of golang.org/x/net and remove or bump it
  3. Switch the proxy to an HTTP CONNECT proxy if upgrading is not possible
  4. Run go mod tidy and rebuild to ensure the vendored copy is current

Example fix

// before: pinned old version in go.mod
// golang.org/x/net v0.0.0-2019...
// after
go get golang.org/x/net@latest && go mod tidy
Defensive patterns

Strategy: try-catch

Type guard

if d, ok := socksDialer.(golangProxy.ContextDialer); !ok {
    return errors.New("SOCKS5 dialer lacks DialContext; upgrade golang.org/x/net")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "SOCKS5 proxy does not support context dialing") {
    return fmt.Errorf("proxy stack too old; upgrade golang.org/x/net or use an HTTP CONNECT proxy")
}

Prevention

When it happens

Trigger: HTTP_PROXY/HTTPS_PROXY (or configured proxy URL) with a socks5/socks5h scheme, where the dialer produced by golangProxy.SOCKS5 fails the ContextDialer type assertion during the agent HTTP request.

Common situations: Pinned/older version of golang.org/x/net where the SOCKS5 dialer did not implement DialContext; vendored or replaced proxy package; tests stubbing proxy.FromURL with a plain dialer.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/3ed661c8b44ef2d1. Report an issue: GitHub.

Appendix: source

Thrown at kernel/util/httprequest.go:202

func dialProxyTunnel(ctx context.Context, proxyURL *url.URL, targetAddr string) (net.Conn, *bufio.Reader, error) {
	proxyAddr, err := proxyAddress(proxyURL)
	if err != nil {
		return nil, nil, err
	}
	dialer := &net.Dialer{Timeout: 30 * time.Second, KeepAlive: 30 * time.Second}
	if strings.EqualFold(proxyURL.Scheme, "socks5") || strings.EqualFold(proxyURL.Scheme, "socks5h") {
		var auth *golangProxy.Auth
		if proxyURL.User != nil {
			password, _ := proxyURL.User.Password()
			auth = &golangProxy.Auth{User: proxyURL.User.Username(), Password: password}
		}
		socksDialer, err := golangProxy.SOCKS5("tcp", proxyAddr, auth, dialer)
		if err != nil {
			return nil, nil, err
		}
		contextDialer, ok := socksDialer.(golangProxy.ContextDialer)
		if !ok {
			return nil, nil, errors.New("SOCKS5 proxy does not support context dialing")
		}
		conn, err := contextDialer.DialContext(ctx, "tcp", targetAddr)
		if err != nil {
			return nil, nil, err
		}
		return conn, bufio.NewReader(conn), nil
	}

	conn, err := dialer.DialContext(ctx, "tcp", proxyAddr)
	if err != nil {
		return nil, nil, err
	}
	if strings.EqualFold(proxyURL.Scheme, "https") {
		tlsConn := tls.Client(conn, &tls.Config{ServerName: proxyURL.Hostname(), NextProtos: []string{"http/1.1"}})
		if err = tlsConn.HandshakeContext(ctx); err != nil {
			conn.Close()
			return nil, nil, err
		}

View on GitHub (pinned to 9f775e8a12)