XTLS/Xray-core · error · errors.Error

stopped after 10 redirects

Error message

stopped after 10 redirects

What it means

Returned by the HTTP client's CheckRedirect policy in the geodata downloader: a redirect chain exceeded 10 hops, so net/http aborted the request before this code could reject the redirect target. It fires when the geodata mirror keeps redirecting (circular or overly deep redirect chains), e.g. mirror sites bouncing between https URLs.

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.

Appendix: 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)