valyala/fasthttp · error
proxy: unknown scheme:
Error message
proxy: unknown scheme:
What it means
getDialFunc in fasthttpproxy builds a dialer from a parsed proxy URL; when the URL scheme is not one of the supported ones (http, https, socks5) it returns this error with the offending scheme appended. It fails fast on proxy configurations the package cannot dial through.
Source
Thrown at fasthttpproxy/dialer.go:144
if proxyURL == nil {
// dial directly
return func(addr string) (net.Conn, error) {
return d.Dial(network, addr)
}, nil
}
switch proxyURL.Scheme {
case "socks5", "socks5h":
proxyDialer, err = proxy.FromURL(proxyURL, d)
if err != nil {
return nil, err
}
case "http":
proxyAddr, auth := addrAndAuth(proxyURL, nil)
proxyDialer = DialerFunc(func(network, addr string) (conn net.Conn, err error) {
return httpProxyDial(d, network, addr, proxyAddr, auth)
})
default:
return nil, errors.New("proxy: unknown scheme: " + proxyURL.Scheme)
}
return func(addr string) (net.Conn, error) {
return proxyDialer.Dial(network, addr)
}, nil
}
// slow path when the proxyURL changes along with the request URL.
var authCache sync.Map
return func(addr string) (conn net.Conn, err error) {
var proxyDialer proxy.Dialer
var proxyURL *url.URL
requestScheme := scheme
if requestScheme == "" {
requestScheme = httpsScheme
if !strings.HasSuffix(addr, colonTLSPort) {
requestScheme = httpScheme
}
}
reqURL := &url.URL{Host: addr, Scheme: requestScheme}View on GitHub (pinned to c96f600972)
Solutions
- Use a supported scheme: http, https, or socks5 in the proxy URL
- Fix the proxy URL: add an explicit scheme (http://host:port) if it is missing
- Pre-parse the proxy URL (url.Parse) and reject unsupported schemes before calling GetDialFunc
- Switch to socks4 via a different library or a local socks5 bridge if socks4 is required
Example fix
// before
proxy := os.Getenv("HTTPS_PROXY") // "socks4://proxy:1080"
dialFunc, err := fasthttpproxy.GetDialFunc(proxy)
// after
u, _ := url.Parse(os.Getenv("HTTPS_PROXY"))
switch u.Scheme {
case "http", "https", "socks5":
dialFunc, err = fasthttpproxy.GetDialFunc(u.String())
default:
err = fmt.Errorf("unsupported proxy scheme %q", u.Scheme)
} Defensive patterns
Strategy: validation
Validate before calling
u, err := url.Parse(proxyURL)
if err != nil || (u.Scheme != "http" && u.Scheme != "https" && u.Scheme != "socks5") {
return fmt.Errorf("unsupported proxy scheme %q", u.Scheme)
} Prevention
- Whitelist http/https/socks5 schemes at startup
- Always include an explicit scheme in proxy URLs
- Sanitize HTTP_PROXY/HTTPS_PROXY env values before use
- Fail fast with a clear message instead of at dial time
When it happens
Trigger: Passing a proxy URL with an unsupported scheme (e.g. socks4, socks4a, ftp, or an empty scheme) to fasthttpproxy.GetDialFunc / fasthttp.ProxyFunc setup; environment variable HTTP_PROXY/HTTPS_PROXY containing an unsupported scheme.
Common situations: Corporate proxies configured as socks4; typos like 'https:...' vs 'http://'; env var set to 'localhost:8080' with no scheme at all; libraries reading standard proxy env vars that include schemes fasthttpproxy doesn't implement.
Related errors
- dont support the network:
- could not connect to proxy addr: %s status code: %d
- fasthttp: pipelined requests' queue has been overflowed. inc
- fasthttp: cannot find whitespace in the first line of respon
- fasthttp: unexpected char at the end of status code
AI-assisted analysis of valyala/fasthttp@c96f600972 (2026-08-31).
Data as JSON: /api/errors/9a815fbaffa55380.
Report an issue: GitHub.