GrepBoard/Manuals
605 manuals ·

HAProxy -c "Warnings were found" but exit 0: use -dW

·Tested on HAProxy 2.8.31 (Docker) · 2026-10·Test scope ↓·5 steps

haproxy -c prints "Warnings were found" yet exits 0. Add -dW to make warnings fail the check before a reload; -q hides the reason for errors.

You ran haproxy -c, reloaded, and a [WARNING] line scrolled past. The check passed and the exit code is 0. To fail on warnings too, check with haproxy -c -dW -f <config file>. A … in the output marks lines left out, such as [NOTICE] lines.

output
Warnings were found.Configuration file is valid…[WARNING]  (1) : config : missing timeouts for frontend 'web'.   | While not properly invalid, you will certainly encounter various problems   | with such a configuration. To fix this, please ensure that all following   | timeouts are set to a non-zero value: 'client', 'connect', 'server'.…

A warning means "not invalid, but you will run into problems", so by default it does not stop startup. This post compares the output and exit code for three cases (clean, warning, error) and shows how to make warnings fail too. The output comes from the official HAProxy 2.8.31 Docker image; only the config file path was changed to /etc/haproxy/haproxy.cfg.

[1] Compare the three cases. The warning came from a defaults section with no timeout lines (warn.cfg); the error came from a balance roundrobbin typo.

ConfigOutputExit code
cleanConfiguration file is valid0
warningWarnings were found. + Configuration file is valid + [WARNING]0
error[ALERT] lines1

The error output, with the line number:

output
…[ALERT]    (1) : config : parsing [/etc/haproxy/haproxy.cfg:15] : balance only supports 'roundrobin', 'static-rr', 'leastconn', 'source', 'uri', 'url_param', 'hdr(name)' and 'rdp-cookie(name)' options.[ALERT]    (1) : config : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg[ALERT]    (1) : config : Fatal errors found in configuration.exit=1

A warning appears together with Configuration file is valid. In this test, Warnings were found. and Configuration file is valid went to standard output, while the [NOTICE] and [WARNING] lines went to standard error.

[2] Read the warning and fix it. This one says the frontend and backend lack the client, connect and server timeouts. Add three lines to defaults and the warning disappears; only Configuration file is valid remains.

/etc/haproxy/haproxy.cfg
defaults    mode http  timeout connect 5s  timeout client  30s  timeout server  30s

The values 5s and 30s are for the test. Choose values that fit your service. For logs of requests cut off by a timeout, see reading a HAProxy log line.

[3] To treat warnings as failures, pass -dW together with -c. The official documentation describes -dW as refusing to start if any warning was emitted while processing the configuration, and says that combined with -c it makes warnings in the checked configuration fail. Same warning config, different exit code:

console
$ haproxy -c -dW -f /etc/haproxy/haproxy.cfg
output
…[WARNING]  (1) : config : missing timeouts for frontend 'web'.…[WARNING]  (1) : config : missing timeouts for backend 'app'.…[ALERT]    (1) : config : Some warnings were found and 'zero-warning' is set. Aborting.exit=1

A clean config still prints Configuration file is valid and exits 0. Putting zero-warning in the global section gave the same result in the test.

[4] Tie it to the pre-reload check. Continue only when the exit code is 0.

console
# haproxy -c -dW -f /etc/haproxy/haproxy.cfg && systemctl reload haproxy

[5] -q hides the reason for an error too. -q turns the output off, so an invalid config prints nothing and only the exit code, 1, tells you.

output
=== bad: -c -qexit=1

A warning config with -c -q exits 0 with no output, so the warning is missed. In automation, drop -q and keep the output when the check fails, or add -dW and judge by the exit code.

Analyze your HAProxy log in the browser ↗ — nothing is uploaded.

#haproxy#config-check#warning#reload