Skip to content
Latchkey

haproxy -c: Check the HAProxy Config

haproxy -c -f <config> parses the configuration, reports errors, prints "Configuration file is valid", and exits without starting the proxy.

haproxy -c is the config gate for HAProxy. Because HAProxy fails hard on a bad config at startup, validating in CI prevents a deploy that would refuse to boot.

What it does

haproxy -c reads the configuration passed with -f, validates the syntax and semantics of every section (global, defaults, frontend, backend, listen), and exits. It prints "Configuration file is valid" and exits 0 on success, or prints [ALERT] lines and exits non-zero on failure.

Common usage

Terminal
haproxy -c -f /etc/haproxy/haproxy.cfg
# check with verbose output
haproxy -c -V -f /etc/haproxy/haproxy.cfg
# check multiple fragment files in order
haproxy -c -f /etc/haproxy/global.cfg -f /etc/haproxy/backends.cfg

Options

FlagWhat it does
-cCheck the config and exit (do not start)
-f <file>Config file to load (repeatable, loaded in order)
-VVerbose: print more detail while checking
-qQuiet: suppress messages
-vvPrint version and build options, including features

In CI

Run haproxy -c -f in a container matching your deploy version, because directive availability changes across HAProxy releases. Split configs load with repeated -f in the same order the service uses. A non-zero exit maps cleanly to a failed pipeline gate.

Common errors in CI

[ALERT] parsing [haproxy.cfg:20] : unknown keyword 'foo' in 'frontend' section means a typo or a version-specific keyword. [ALERT] Error(s) found in configuration file summarizes the failure. [ALERT] Starting frontend ... cannot bind socket (Address already in use) appears when you accidentally start instead of check, or the port is taken. "haproxy: command not found" means the binary is missing on the runner.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →