valyala/fasthttp · error

dont support the network:

Error message

dont support the network: 

What it means

TCPDialer.Dial only supports the 'tcp' network; any other network value passed to Dial returns 'dont support the network: <network>'. The fasthttpproxy Dialer intentionally restricts dialing to TCP.

Source

Thrown at fasthttpproxy/dialer.go:203

		return proxyDialer.Dial(network, addr)
	}, nil
}

// Dial is solely for implementing the proxy.Dialer interface.
func (d *Dialer) Dial(network, addr string) (net.Conn, error) {
	if network == "tcp4" {
		if d.Timeout > 0 {
			return d.DialTimeout(addr, d.Timeout)
		}
		return d.TCPDialer.Dial(addr)
	}
	if network == "tcp" {
		if d.Timeout > 0 {
			return d.DialDualStackTimeout(addr, d.Timeout)
		}
		return d.TCPDialer.DialDualStack(addr)
	}
	err := errors.New("dont support the network: " + network)
	return nil, err
}

func (d *Dialer) connectTimeout() time.Duration {
	return d.ConnectTimeout
}

// In the httpProxyDial function, the proxy.Dialer that implements
// this interface can retrieve timeout information when sending the CONNECT
// method to the HTTP proxy.
type httpProxyDialer interface {
	connectTimeout() time.Duration
}

// DialerFunc Make a function of type func(network, addr string) (net.Conn, error)
// implement the proxy.Dialer interface.
type DialerFunc func(network, addr string) (net.Conn, error)

View on GitHub (pinned to c96f600972)

Solutions

  1. Pass network="tcp" to Dialer.Dial
  2. Normalize/alias tcp4/tcp6 to "tcp" before calling, or use the raw net.Dialer for those cases
  3. Use a unix-socket capable dialer (net.Dial) when 'unix' is needed instead of fasthttpproxy.Dialer

Example fix

// before
conn, err := dialer.Dial("tcp4", "example.com:80")
// after
network := "tcp"
conn, err := dialer.Dial(network, "example.com:80")
Defensive patterns

Strategy: validation

Validate before calling

if network != "tcp" {
    return fmt.Errorf("fasthttpproxy only supports tcp, got %q", network)
}

Prevention

When it happens

Trigger: Calling the fasthttpproxy Dialer's Dial (e.g. as a proxy.Dialer implementation) with network values like 'udp', 'unix', or 'tcp4'/'tcp6' variants — anything other than exactly "tcp". Also reached indirectly via httpProxyDial when the configured network differs.

Common situations: Wiring fasthttpproxy.Dialer into generic dial interfaces that pass the network string from a config file set to 'unix'; callers assuming tcp4/tcp6 are accepted; proxy frameworks invoking Dialer.Dial(network, addr) with non-tcp networks.

Related errors


AI-assisted analysis of valyala/fasthttp@c96f600972 (2026-08-31). Data as JSON: /api/errors/0f9ba7421c6b7860. Report an issue: GitHub.