XTLS/Xray-core · error

failed to build routing configuration

Error message

failed to build routing configuration

What it means

Config.Build wraps a failure of RouterConfig.Build while compiling the "routing"/"rules" section. One of the routing rules or balancers failed to build (e.g. missing target tag), so the router app cannot be added to the core config.

Solutions

  1. Validate routing rule syntax and matcher types
  2. Remove or fix the offending rule indicated by the wrapped error
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at infra/conf/xray.go:586 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at infra/conf/xray.go:586

			return nil, errors.New("failed to build stats configuration").Base(err)
		}
		config.App = append(config.App, serial.ToTypedMessage(statsConf))
	}

	var logConfMsg *serial.TypedMessage
	if c.LogConfig != nil {
		logConfMsg = serial.ToTypedMessage(c.LogConfig.Build())
	} else {
		logConfMsg = serial.ToTypedMessage(DefaultLogConfig())
	}
	// let logger module be the first App to start,
	// so that other modules could print log during initiating
	config.App = append([]*serial.TypedMessage{logConfMsg}, config.App...)

	if c.RouterConfig != nil {
		routerConfig, err := c.RouterConfig.Build()
		if err != nil {
			return nil, errors.New("failed to build routing configuration").Base(err)
		}
		config.App = append(config.App, serial.ToTypedMessage(routerConfig))
	}

	if c.DNSConfig != nil {
		dnsApp, err := c.DNSConfig.Build()
		if err != nil {
			return nil, errors.New("failed to build DNS configuration").Base(err)
		}
		config.App = append(config.App, serial.ToTypedMessage(dnsApp))
	}

	if c.Policy != nil {
		pc, err := c.Policy.Build()
		if err != nil {
			return nil, errors.New("failed to build policy configuration").Base(err)
		}
		config.App = append(config.App, serial.ToTypedMessage(pc))

View on GitHub (pinned to 7d214f8b09)