Skip to content
Latchkey

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

  1. Run haproxy -c -f to list every error with file and line.
  2. Fix undefined backends, misplaced directives, or bad values it names.
  3. Re-run until the check prints "Configuration file is valid".
Terminal
haproxy -c -f /etc/haproxy/haproxy.cfg

Gate 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.cfg

How to prevent it

  • Run haproxy -c as a required CI step.
  • Keep backend references in sync with defined backends.
  • Place directives only in sections that allow them.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →