caddyserver/caddy · error
%s:%d: unrecognized directive: %s
Error message
%s:%d: unrecognized directive: %s
What it means
Error "%s:%d: unrecognized directive: %s" thrown in caddyserver/caddy.
Source
Thrown at caddyconfig/httpcaddyfile/httptype.go:136
}
// evaluate each directive ("segment") in this block
for _, segment := range sb.block.Segments {
dir := segment.Directive()
if strings.HasPrefix(dir, matcherPrefix) {
// matcher definitions were pre-processed
continue
}
dirFunc, ok := registeredDirectives[dir]
if !ok {
tkn := segment[0]
message := "%s:%d: unrecognized directive: %s"
if !sb.block.HasBraces {
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)
}
View on GitHub (pinned to 50e54ee279)
Solutions
- Fix the directive name spelling, or remove the line if it is not a valid directive.
- Check the Caddy documentation for the correct directive name and ensure the needed module is built in.
When it happens
Trigger: Thrown at caddyconfig/httpcaddyfile/httptype.go:136 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/6202fbc43eb4675f.
Report an issue: GitHub.