XTLS/Xray-core · error

Trojan fallbacks: invalid PROXY protocol version, "xver" onl

Error message

Trojan fallbacks: invalid PROXY protocol version, "xver" only accepts 0, 1, 2

What it means

Thrown when a Trojan fallback's 'xver' (PROXY protocol version) is greater than 2. Only 0 (off), 1 (v1 text) and 2 (v2 binary) exist; the config check rejects anything larger, including the common mistake of copying the year or a bool.

Source

Thrown at infra/conf/trojan.go:200

				if strings.HasPrefix(fb.Dest, "@@") && (runtime.GOOS == "linux" || runtime.GOOS == "android") {
					fullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work with haproxy
					copy(fullAddr, fb.Dest[1:])
					fb.Dest = string(fullAddr)
				}
			} else {
				if _, err := strconv.Atoi(fb.Dest); err == nil {
					fb.Dest = "localhost:" + fb.Dest
				}
				if _, _, err := net.SplitHostPort(fb.Dest); err == nil {
					fb.Type = "tcp"
				}
			}
		}
		if fb.Type == "" {
			return nil, errors.New(`Trojan fallbacks: please fill in a valid value for every "dest"`)
		}
		if fb.Xver > 2 {
			return nil, errors.New(`Trojan fallbacks: invalid PROXY protocol version, "xver" only accepts 0, 1, 2`)
		}
	}

	return config, nil
}

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Set "xver" to 0, 1, or 2 depending on whether the dest backend speaks PROXY protocol v1/v2
  2. If the backend (e.g. nginx) has proxy_protocol off, use 0

Example fix

// before
{ "dest": 80, "xver": 3 }
// after
{ "dest": 80, "xver": 1 }
Defensive patterns

Strategy: validation

Validate before calling

xver := gjson.Get(fb.Raw, "xver").Int()
if xver < 0 || xver > 2 {
    return fmt.Errorf("fallback xver must be 0, 1 or 2, got %d", xver)
}

Prevention

When it happens

Trigger: Setting "xver": 3 or higher in a Trojan inbound fallback entry.

Common situations: Misreading xver as a boolean/flag and writing a large number, or intending 'enabled' and typing an arbitrary value like 1/0 but fat-fingering 3+.

Related errors


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