/errors/caddy/unrecognized-directive
Caddy: Caddyfile:2: unrecognized directive
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · v2.11.7 h1:yj0Y4fYZGPkSvibBJ1sTWE33xC0fxztVyXEW5iIdUT4=updated 2026-10-20
- tool
- Caddy
- exit code
- 1
- versions
- Caddy 2
- os
- any
Caddy parses a Caddyfile into its JSON configuration before it starts. A line inside a site block whose first word is not a known directive stops caddy run, caddy validate and caddy adapt with Caddyfile:2: unrecognized directive: reverse_proxi, where 2 is the line number.
Reproduce it
caddy adapt converts the Caddyfile without starting a server:
printf 'example.com {\n\treverse_proxi localhost:3000\n}\n' > Caddyfile
# Caddy logs as JSON; sed removes the timestamp field
caddy adapt --config Caddyfile 2>&1 | sed -E 's/"ts":[0-9.]+,//'
exit "${PIPESTATUS[0]}"Output · exit 1
{"level":"error","msg":"Caddyfile:2: unrecognized directive: reverse_proxi"}Fix it
example.com {
reverse_proxy localhost:3000
}If the directive is right but comes from a plugin, check whether your binary has it:
caddy list-modules | grep -i rate_limitGlobal options belong in the block at the very top, without an address:
{
email admin@example.com
}
example.com {
reverse_proxy localhost:3000
}Sources
Related pages
flags · caddycaddy fmt --overwrite and --diff: format a Caddyfilecaddy fmt prints a Caddyfile in canonical style with tabs; --overwrite rewrites the file in place, --diff shows the changes, and it exits non-zero if needed.compare · caddyCaddy vs nginx: HTTPS, configuration and performance comparedCaddy gets and renews HTTPS certificates automatically with a few lines of config; nginx needs certbot or similar but has more modules, docs and tuning.glossary · nginxWhat is a reverse proxy?A reverse proxy is a server in front of your applications that receives client requests and forwards them to backends, adding TLS, caching and balancing.