GrepBoard/Manuals
605 manuals ·

Fix HAProxy "cannot bind socket" (Starting frontend / Binding)

·Tested on HAProxy 3.4.7 (Docker haproxy:lts) · Ubuntu 24.04 haproxy 2.8.30 · 2026-10·Test scope ↓·6 steps

HAProxy "cannot bind socket": a bind address or port failed to open. The reason in parentheses means port in use, missing IP or permission.

output
[ALERT]    (8) : Binding [/usr/local/etc/haproxy/port80.cfg:13] for frontend web: protocol tcpv4: cannot bind socket (Address already in use) for [0.0.0.0:80].[ALERT]    (8) : [haproxy.main()] Some protocols failed to start their listeners! Exiting.

HAProxy could not open 0.0.0.0:80 from the bind line (config line 13) of frontend web, so it stopped. The text in parentheses is the cause. (Address already in use) means another process holds the port — find it with ss -ltnp and sort it out.

[1] Match the wording to your version. Same "missing IP" case on three versions:

VersionMessage
3.4.7Binding [<file>:13] for frontend web: protocol tcpv4: cannot bind socket (Cannot assign requested address) for [192.0.2.10:80].
2.8.30 (Ubuntu 24.04)Binding [<file>:13] for frontend web: cannot bind socket (Cannot assign requested address) for [192.0.2.10:80]
2.0.35 (end-of-life)Starting frontend web: cannot bind socket [192.0.2.10:80]

The old Starting frontend … form gives no reason. With it, check the three causes below in order.

[2] A config check does not catch it. Port in use, a missing IP, and two frontends on the same port all gave exit code 0 from haproxy -c, because sockets are only opened at startup. A passing -c before reload does not rule this error out.

[3] For (Address already in use), find the owner of the port.

console
$ sudo ss -ltnp "sport = :80"

nginx or Apache already listening on 80 on the same host is the usual case. Reading the output and cleaning up works the same as in nginx bind() failed (98). Stopping that process takes its service down; if you need both, move one to another port.

[4] For (Cannot assign requested address), the IP does not exist on this server.

output
[ALERT]    (8) : Binding [/usr/local/etc/haproxy/noaddr.cfg:13] for frontend web: protocol tcpv4: cannot bind socket (Cannot assign requested address) for [192.0.2.10:80].

Check the real addresses with ip -br addr and fix bind, or drop the address and use bind :80. If you bind a floating virtual IP (keepalived and the like), the standby node does not have that IP and fails to start. The Linux kernel docs describe ip_nonlocal_bind as allowing processes to bind() to non-local IP addresses, "but may break some applications". It is a host-wide setting that affects other services too, so assess that before using it (it was not changed here).

[5] For (Permission denied), a non-root user tried to open a port below 1024.

output
[ALERT]    (7) : Binding [/usr/local/etc/haproxy/port80.cfg:13] for frontend web: protocol tcpv4: cannot bind socket (Permission denied) for [0.0.0.0:80].

The official haproxy Docker image runs as uid=99(haproxy). With this test's Docker defaults that user could still open 80, but with the container's net.ipv4.ip_unprivileged_port_start set to 1024 it failed as above. The simplest fix is to listen on a high port such as 8080 inside the container and publish it as 80 (-p 80:8080).

[6] Start again and confirm it listens.

console
$ haproxy -c -f /etc/haproxy/haproxy.cfg$ sudo systemctl restart haproxy$ sudo ss -ltnp "sport = :80"

restart drops connections, so do it at a quiet time. If it fails again, find the same cannot bind socket line in journalctl -u haproxy -n 20 and reread the reason. To make -c fail on warnings, see HAProxy -c "Warnings were found".

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

#haproxy#bind#cannot-bind-socket#ss