caddyserver/caddy · error

ambiguous site definition

Error message

ambiguous site definition: %s

What it means

Two server blocks in the same pairing (same host bound to the same listener address) contain the identical site address key. Their routes would incorrectly merge into one server (issue #4635), so serversFromPairings rejects the config as ambiguous.

Solutions

  1. Make the site addresses unambiguous: combine the conflicting site blocks or give each site a distinct address so routes are not merged ambiguously.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at caddyconfig/httpcaddyfile/httptype.go:588 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/38e9e88d67f31670. Report an issue: GitHub.

Appendix: source

Thrown at caddyconfig/httpcaddyfile/httptype.go:588

	}
	autoHTTPS := []string{}
	if ah, ok := options["auto_https"].([]string); ok {
		autoHTTPS = ah
	}

	for i, p := range pairings {
		// detect ambiguous site definitions: server blocks which
		// have the same host bound to the same interface (listener
		// address), otherwise their routes will improperly be added
		// to the same server (see issue #4635)
		for j, sblock1 := range p.serverBlocks {
			for _, key := range sblock1.block.GetKeysText() {
				for k, sblock2 := range p.serverBlocks {
					if k == j {
						continue
					}
					if slices.Contains(sblock2.block.GetKeysText(), key) {
						return nil, fmt.Errorf("ambiguous site definition: %s", key)
					}
				}
			}
		}

		var (
			addresses []string
			protocols [][]string
		)

		for _, addressWithProtocols := range p.addressesWithProtocols {
			addresses = append(addresses, addressWithProtocols.address)
			protocols = append(protocols, addressWithProtocols.protocols)
		}

		srv := &caddyhttp.Server{
			Listen:          addresses,
			ListenProtocols: protocols,

View on GitHub (pinned to 50e54ee279)