HAProxy "config ... has errors" (haproxy -c) in CI
haproxy -c validated the configuration and found fatal errors, so HAProxy refuses to start. The check prints each error with its file and line; the job fails until the config passes.
What this error means
haproxy -c -f exits non-zero with "[ALERT] ... Fatal errors found in configuration" and one or more lines pointing at the offending directives.
haproxy
[ALERT] (1) : config : Fatal errors found in configuration.
[ALERT] (1) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
Common causes
A backend or server reference is invalid
A use_backend or default_backend points at a backend that is not defined, so the check fails fatally.
A directive in the wrong section
A keyword placed in a section that does not allow it (a frontend option in a backend, or vice versa) triggers a fatal error.
How to fix it
Run the check and fix each reported line
- Run
haproxy -c -fto list every error with file and line. - Fix undefined backends, misplaced directives, or bad values it names.
- Re-run until the check prints "Configuration file is valid".
Terminal
haproxy -c -f /etc/haproxy/haproxy.cfgGate the config check in CI
Run the check as a required step so a fatal config error fails the pipeline before deploy.
.github/workflows/ci.yml
- name: Validate HAProxy config
run: haproxy -c -f haproxy.cfgHow to prevent it
- Run
haproxy -cas a required CI step. - Keep backend references in sync with defined backends.
- Place directives only in sections that allow them.
Related guides
HAProxy "parsing [cfg:line] unknown keyword" in CIFix HAProxy "parsing [haproxy.cfg:NN] : unknown keyword" in CI - a directive is misspelled, deprecated, or no…
NGINX Ingress "[emerg] unknown directive" in CIFix NGINX Ingress "[emerg] unknown directive" in CI - a snippet annotation injected a directive nginx does no…
Traefik "the service ... does not exist" in CIFix Traefik "the service ... does not exist" in CI - a router points at a service name that is not defined in…