HAProxy "parsing [cfg:line] unknown keyword" in CI
HAProxy hit a keyword it does not recognize in the section where it appears. The keyword is misspelled, removed in this HAProxy version, or only valid in a different section, so parsing stops with the file and line.
What this error means
haproxy -c fails with "parsing [haproxy.cfg:42] : unknown keyword 'X' in '<section>' section" and refuses to load.
[ALERT] (1) : parsing [/etc/haproxy/haproxy.cfg:42] : unknown keyword 'reqrep' in 'backend' section.
Common causes
A deprecated or removed keyword
Keywords like reqrep were removed in newer HAProxy versions in favor of http-request, so an old config no longer parses.
A keyword used in the wrong section
A directive valid only in a frontend or global section appears in a backend, so it is unknown there.
How to fix it
Replace the keyword with the current form
- Read the file and line in the parse error to find the unknown keyword.
- Replace it with the supported directive for your HAProxy version.
- Re-run
haproxy -cto confirm the config parses.
# old: reqrep ^([^\ ]*)\ /old/(.*) \1\ /new/\2
http-request set-path /new/%[path,regsub(^/old/,/)]Pin the HAProxy version you validate against
Check the config with the same HAProxy version you deploy so keyword availability matches.
docker run --rm -v "$PWD:/cfg" haproxy:2.9 \
haproxy -c -f /cfg/haproxy.cfgHow to prevent it
- Track keyword deprecations when upgrading HAProxy.
- Validate config against the deployed HAProxy version in CI.
- Keep directives in the sections that allow them.