Home › Docker

driver failed programming external connectivity on endpoint (Docker) — how to fix

Error response from daemon: driver failed programming external connectivity on endpoint web (3f2a...): Bind for 0.0.0.0:80 failed: port is already allocated

Quick fix: Read the end of the message. For port is already allocated / address already in use, find the holder with sudo ss -ltnp 'sport = :80' or docker ps --filter publish=80 and stop it or use another host port (-p 8080:80). For iptables errors (No chain/target/match by that name), run sudo systemctl restart docker after any firewall reload.

What it means

When you publish a port (docker run -p 80:80 or ports: in Compose), Docker's bridge driver adds NAT rules in iptables and usually starts a docker-proxy process bound to the host port. If any of that fails, the container is created but cannot start, and you get this message. The useful part is after the endpoint ID.

Cause 1: the host port is already in use

... Bind for 0.0.0.0:80 failed: port is already allocated
... listen tcp4 0.0.0.0:80: bind: address already in use

"Port is already allocated" means another container holds it; "address already in use" usually means a host process (nginx, Apache, another dev server) does.

docker ps --filter "publish=80"
sudo ss -ltnp 'sport = :80'

Then stop the other container (docker stop <name>), stop the host service (sudo systemctl stop nginx), or map a different host port:

docker run -p 8080:80 nginx

In Compose, an old stack from another project directory can still hold the port. docker compose ls lists running projects; docker compose -p <project> down stops one. More detail on the port is already allocated page.

Cause 2: iptables rules were flushed (firewall reload)

... (iptables failed: iptables --wait -t nat -A DOCKER ... iptables: No chain/target/match by that name.

Docker creates its own chains (DOCKER, DOCKER-USER, ...) at daemon start. Reloading firewalld, restarting ufw, or running a script that flushes iptables deletes them, and new containers can't be wired up. Restart the daemon to recreate the chains:

sudo systemctl restart docker

Restarting Docker stops running containers unless they have a restart policy (--restart unless-stopped) or live-restore is enabled. If a firewall service keeps wiping the rules, make sure it starts before Docker, or configure it to leave Docker's chains alone.

Cause 3: stale state after a crash or upgrade

Sometimes Docker thinks a port is allocated by a container that no longer exists, often after an unclean shutdown. Remove stopped containers and unused networks, then restart the daemon:

docker container prune
docker network prune
sudo systemctl restart docker

On Docker Desktop (Windows/macOS), use Restart from the whale menu. On Windows, a port can also be reserved by the OS itself (Hyper-V/WinNAT excluded port ranges); check with:

netsh interface ipv4 show excludedportrange protocol=tcp

If your port is inside one of the listed ranges, choose a port outside it.

Cause 4: binding to an IP the host doesn't have

... listen tcp4 192.168.1.10:80: bind: cannot assign requested address

-p 192.168.1.10:80:80 only works if the host has that address. Check ip -4 addr, use the right IP, or drop it to bind on all interfaces (-p 80:80) or localhost only (-p 127.0.0.1:80:80).

Cause 5: privileged port with rootless Docker

Rootless Docker cannot bind ports below 1024 by default (permission denied). Use a high port such as -p 8080:80, or lower the unprivileged port start on the host:

sudo sysctl net.ipv4.ip_unprivileged_port_start=80

Last updated 2026-12-03.