XTLS/Xray-core · error · errors.Error

stopped after 10 redirects

Error message

stopped after 10 redirects

What it means

CheckRedirect hook on the HTTPS geodata client: net/http by default allows up to 10 redirects; this hook counts them via len(via) >= 10 and stops the chain with this error to prevent redirect loops.

Source

Thrown at app/geodata/download.go:115

						return nil, err
					}
					host, _, _ := net.SplitHostPort(address)
					tlsConn := utls.UClient(conn, &utls.Config{ServerName: host}, utls.HelloChrome_Auto)
					handshakeCtx, cancel := context.WithTimeout(ctx, idleTimeout)
					defer cancel()
					if err := tlsConn.HandshakeContext(handshakeCtx); err != nil {
						conn.Close()
						return nil, err
					}
					return tlsConn, nil
				},
			},
			CheckRedirect: func(req *http.Request, via []*http.Request) error {
				if req.URL.Scheme != "https" {
					return errors.New("redirected to non-https URL: ", req.URL.String())
				}
				if len(via) >= 10 {
					return errors.New("stopped after 10 redirects")
				}
				return nil
			},
		}
	} else {
		return &http.Client{
			Transport: &http.Transport{
				Proxy:                 nil,
				DisableKeepAlives:     true,
				DialContext:           dial,
				ResponseHeaderTimeout: idleTimeout,
			},
			CheckRedirect: func(req *http.Request, via []*http.Request) error {
				if req.URL.Scheme != "https" {
					return errors.New("redirected to non-https URL: ", req.URL.String())
				}
				if len(via) >= 10 {
					return errors.New("stopped after 10 redirects")

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Pin the final https URL directly in the geodata asset config so no redirects are needed
  2. Diagnose the loop: curl -sIL <asset-url> and count/inspect Location headers
  3. Switch to a stable mirror (raw.githubusercontent.com or jsdelivr)
Defensive patterns

Strategy: try-catch

Try / catch

err := d.download(assets)
if err != nil && strings.Contains(err.Error(), "stopped after 10 redirects") {
    // replace asset URL with the direct final URL instead of retrying blindly
}

Prevention

When it happens

Trigger: The geodata asset URL enters a redirect cycle (A -> B -> A, or a self-redirecting mirror) exceeding 10 hops.

Common situations: Misconfigured CDN or mirror with a redirect loop; a proxy/MITM rewriting each hop; cookie-less clients bounced between regional mirrors.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/bb7547af87f1e943. Report an issue: GitHub.