XTLS/Xray-core · warning

failed to find the default "path" config

Error message

failed to find the default "path" config

What it means

The name+alpn fallback group contains path-specific entries but no empty-path default: lookup pfb[path] missed (path sniffed from the HTTP request line) and pfb[""] is nil. Path sniffing only runs when the first bytes look like an HTTP method and are not h2c.

Source

Thrown at proxy/trojan/server.go:447

							break
						}
						if k == '?' || k == ' ' {
							path = string(firstBytes[i:j])
							errors.LogInfo(ctx, "realPath = "+path)
							if pfb[path] == nil {
								path = ""
							}
							break
						}
					}
					break
				}
			}
		}
	}
	fb := pfb[path]
	if fb == nil {
		return errors.New(`failed to find the default "path" config`).AtWarning()
	}

	ctx, cancel := context.WithCancel(ctx)
	timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle)
	ctx = policy.ContextWithBufferPolicy(ctx, sessionPolicy.Buffer)

	var conn net.Conn
	if err := retry.ExponentialBackoff(5, 100).On(func() error {
		var dialer net.Dialer
		conn, err = dialer.DialContext(ctx, fb.Type, fb.Dest)
		if err != nil {
			return err
		}
		return nil
	}); err != nil {
		return errors.New("failed to dial to " + fb.Dest).Base(err).AtWarning()
	}
	defer conn.Close()

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Add an entry with no 'path' under the same name/alpn as the universal default
  2. Compare the logged sniffed path with the configured paths character by character
  3. Keep path strings exactly as the client requests them, including the leading '/'

Example fix

// json: last entry is the pathless default
"fallbacks": [
  {"name": "ws.example.com", "path": "/ws", "dest": 9000},
  {"name": "ws.example.com", "dest": 8080}
]
Defensive patterns

Strategy: validation

Validate before calling

// ensure path-based groups keep a pathless default
func validatePaths(fbs []Fallback) error {
    type key struct{ name, alpn string }
    defaults := map[key]bool{}
    for _, f := range fbs {
        k := key{f.Name, f.Alpn}
        if f.Path == "" { defaults[k] = true }
    }
    for _, f := range fbs {
        if f.Path != "" && !defaults[key{f.Name, f.Alpn}] {
            return errors.New("path fallbacks under '" + f.Name + "' lack a pathless default")
        }
    }
    return nil
}

Prevention

When it happens

Trigger: Multiple path-based fallbacks are configured for this name/alpn, the client's HTTP path does not equal any configured 'path', and no pathless default entry exists in the same group.

Common situations: WebSocket/gRPC fallback paths mistyped (missing leading slash, different case), path-based routing added without a catch-all, or a non-HTTP client sending bytes that accidentally parse into an unmatched path.

Related errors


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