caddyserver/caddy · error

parsing caddyfile tokens for '%s': %v

Error message

parsing caddyfile tokens for '%s': %v

What it means

Error "parsing caddyfile tokens for '%s': %v" thrown in caddyserver/caddy.

Source

Thrown at caddyconfig/httpcaddyfile/httptype.go:152

					message += "\nDid you mean to define a second site? If so, you must use curly braces around each site to separate their configurations."
				}
				return nil, warnings, fmt.Errorf(message, tkn.File, tkn.Line, dir)
			}

			h := Helper{
				Dispenser:    caddyfile.NewDispenser(segment),
				options:      options,
				warnings:     &warnings,
				matcherDefs:  matcherDefs,
				parentBlock:  sb.block,
				groupCounter: gc,
				State:        state,
				BlockState:   state,
			}

			results, err := dirFunc(h)
			if err != nil {
				return nil, warnings, fmt.Errorf("parsing caddyfile tokens for '%s': %v", dir, err)
			}

			dir = normalizeDirectiveName(dir)

			for _, result := range results {
				result.directive = dir
				sb.pile[result.Class] = append(sb.pile[result.Class], result)
			}

			// specially handle named routes that were pulled out from
			// the invoke directive, which could be nested anywhere within
			// some subroutes in this directive; we add them to the pile
			// for this server block
			if state[namedRouteKey] != nil {
				for name := range state[namedRouteKey].(map[string]struct{}) {
					result := ConfigValue{Class: namedRouteKey, Value: name}
					sb.pile[result.Class] = append(sb.pile[result.Class], result)
				}

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Fix the syntax error inside the referenced directive's block; the wrapped error shows the exact token problem.

When it happens

Trigger: Thrown at caddyconfig/httpcaddyfile/httptype.go:152 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/536f1c6a40bc88c7. Report an issue: GitHub.