Docker: driver failed programming external connectivity on endpoint
The daemon could not set up the host side of a published port. Separate a bind conflict from missing iptables chains, then fix the right one.

Introduction & Quick Summary
docker compose up brings up the database container and then fails on the web container:
Error response from daemon: driver failed programming external connectivity on
endpoint shop-web-1 (3f9c1a7b2e4d): Error starting userland proxy:
listen tcp4 0.0.0.0:8080: bind: address already in useQuick answer: Docker could not set up the host side of the published port. Something already owns 8080, or the kernel rules that forward traffic into the container are missing. Find out which of the two you have before restarting anything.
# which process holds the port (needs root for the pid column)
sudo ss -tlnp 'sport = :8080'
# containers that are stopped but still hold the port via docker-proxy
docker ps -a --filter "publish=8080"The full error is a chain of three parts, and the middle one is the part people skip:
driver failed programming external connectivity on endpoint NAME— the bridge driver was configuring the host side for that container.Error starting userland proxy: listen tcp4 ... bind: address already in use—docker-proxycould not bind the host port.iptables failed: ... No chain/target/match by that name— theDOCKERchain itself is gone.
Those two tails have different causes. A bind failure is a port conflict on the host. A missing chain means something flushed or reloaded the firewall rules Docker depends on, and restarting the container will keep failing until the daemon rebuilds them.
Core Mechanics, Signatures & Reproducible Setup
Reproduce the conflict deterministically:
docker network create repro 2>/dev/null || true
docker run -d --name a -p 8080:80 nginx:alpine
docker run --rm -p 8080:80 nginx:alpine # fails with the bind message
docker rm -f aReproduce the missing-chain variant on a test host only, because it drops connectivity for every container:
sudo iptables -t nat -F DOCKER
docker run --rm -p 8081:80 nginx:alpine # fails with "No chain/target/match"
sudo systemctl restart docker # daemon rebuilds its chains| Message fragment | Meaning | Who owns the fix |
|---|---|---|
Error starting userland proxy: bind: address already in use | host port taken | you, by freeing or remapping the port |
iptables failed: iptables --wait -t nat -A DOCKER ... | DOCKER chain absent | daemon restart, then firewall configuration |
No chain/target/match by that name | tables or chains flushed | daemon restart plus a persistent firewall rule set |
failed to set up container networking | bridge or veth missing | network recreate, CNI or kernel module check |
listen tcp4 0.0.0.0:80: bind: permission denied | privileged port in rootless mode | ip_unprivileged_port_start or a higher port |
address already in use on [::]:8080 | IPv6 listener separate from IPv4 | bind both families or disable IPv6 publish |
Key Comparison Table
| Publish form | Host interfaces bound | Typical failure | Better when |
|---|---|---|---|
-p 8080:80 | all interfaces, IPv4 and IPv6 | any local listener conflicts | the service must be public |
-p 127.0.0.1:8080:80 | loopback only | port used by another loopback service | reverse proxy runs on the host |
-p 8080:80/tcp and -p 8080:80/udp | one protocol each | UDP port still free, TCP taken | both protocols needed |
network_mode: host | host stack, no proxy | every host port is shared | performance-critical local work |
-p 127.0.0.1::80 | random high port on loopback | client cannot find the port | ephemeral test runs |
Fixes ranked by how much they change:
| Fix | Effort | Effect on the running system | Notes |
|---|---|---|---|
| Change the host port | seconds | none | compose file edit and recreate |
| Stop the conflicting process | seconds | that process goes down | check first with ss |
| Remove a stale container | seconds | its data may be lost | docker rm keeps volumes |
| Restart the Docker daemon | a minute | every container restarts | rebuilds missing chains |
Set userland-proxy: false | daemon config | no docker-proxy, iptables only | does not fix a chain problem |
| Recreate the Docker network | seconds per network | containers detach | fixes missing veth or bridge |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Reading the endpoint name to find the real container
endpoint shop-web-1 is the container, not the compose service alias. When several replicas publish the same port, only one gets it and the others fail:
docker ps --format '{{.Names}}\t{{.Ports}}' | column -t
docker compose ps --format 'table {{.Name}}\t{{.Publishers}}'Compose with scale or a deploy.replicas block must not publish a fixed host port; put a reverse proxy in front and publish the port on the proxy only. The failure otherwise appears on the second and third replica and looks random.
2. Firewall reloads that delete Docker's chains
firewalld --reload, ufw reload, nft flush ruleset and cloud-init reruns can remove DOCKER, DOCKER-USER and DOCKER-ISOLATION-STAGE-*. Docker does not notice until the next container start:
sudo iptables -t nat -L DOCKER -n | head
sudo nft list ruleset | grep -i docker | head
sudo systemctl restart dockerOn hosts where the firewall is managed by a tool, add the Docker interface to its trusted zone instead of flushing:
sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0
sudo firewall-cmd --reloadThe DOCKER-USER chain is the supported place for custom filtering; rules added directly to DOCKER are lost the moment the daemon restarts.
3. Stale containers and docker-proxy leftovers
docker ps -a --filter status=exited --format '{{.ID}} {{.Names}} {{.Ports}}'
docker compose down --remove-orphansA container in Exited state does not hold a port, but a docker-proxy from a container that was killed with SIGKILL can linger for a moment, and a Compose project created with an older file keeps an old container around as an orphan. docker compose up --force-recreate then fails on the port the orphan still owns. --remove-orphans clears it.
4. Rootless Docker and ports below 1024
Rootless mode runs the daemon inside a user namespace, where net.ipv4.ip_unprivileged_port_start is 1024 by default:
docker run --rm -p 80:80 nginx:alpine
# listen tcp4 0.0.0.0:80: bind: permission denied
sysctl net.ipv4.ip_unprivileged_port_start # 1024
sudo sysctl -w net.ipv4.ip_unprivileged_port_start=80Rootless users can set the value inside their own namespace without root on the host. Setting it to 0 allows every port for that user. The alternative is publishing 8080:80 and letting the host reverse proxy own port 80.
5. Docker Desktop, WSL2 and reserved Windows ranges
On Windows the failure often comes from Hyper-V reserving the port rather than from a listener:
Error starting userland proxy: listen tcp4 0.0.0.0:5000: bind: address already in use
netsh interface ipv4 show excludedportrange protocol=tcpIf the port sits in a reserved range, either pick a port outside it or reserve the port for Docker before the ranges are assigned:
net stop winnat
netsh int ipv4 add excludedportrange protocol=tcp startport=5000 numberofports=1
net start winnatWSL2 also keeps wslrelay processes that hold published ports for a few seconds after a container stops, which is why an immediate retry fails and a retry a minute later succeeds.
6. network_mode: host and custom networks
services:
proxy:
image: nginx:alpine
network_mode: host
ports: ["80:80"] # ignored, and misleadingWith host networking the container shares the host stack, so ports is ignored and any host listener on 80 conflicts at process start rather than at container start. On macvlan or ipvlan networks the host cannot reach the container's IP unless a macvlan shim interface exists, and the publish flag does nothing because the container has its own IP. Validate a compose file before rebuilding the stack with the docker-compose viewer, and confirm the published endpoint answers with the cURL builder once it is up.
Common Compilation/Runtime Mistakes & Version Gotchas
Restarting the daemon first. It restarts every container on the host, including production ones, and it does not help when another process owns the port. Use ss first.
Adding privileged: true. Privileged mode does not grant a host port; the conflict is in the host network namespace, not in capabilities.
Setting iptables: false to silence the error. The container starts and then has no NAT, so published ports silently stop working and outbound container traffic loses source translation.
Assuming a container restart releases the port instantly. The kernel may keep TIME_WAIT sockets, and docker-proxy exits asynchronously. A short wait or a different host port is more reliable than looping docker compose up.
Publishing on all interfaces without meaning it. -p 8080:80 binds 0.0.0.0 and [::], so a database published for local development becomes reachable from the LAN. Bind 127.0.0.1 unless the service is meant to be public.
Version notes. Docker Engine 28 changed the default behaviour of published ports to route through the host rather than the userland proxy for some configurations, which alters the exact error text but not the causes. docker compose v2 parses deploy.replicas locally and now warns when replicas publish a fixed port, where v1 silently failed. On macOS, Docker Desktop's virtiofs and gRPC-FUSE file sharing do not affect ports; slow starts there are unrelated.
Reference material: Packet filtering and firewalls and Docker networking.
Official references
primary documentationThe Docker documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Docker work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Docker guides
All Docker guidesDocker build: failed to compute cache key: not found
BuildKit cannot hash a file that is not in the context. Correct the context path, the .dockerignore rules, or the COPY source and stage name.
Docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock
An endpoint mismatch, a stopped daemon, or a missing socket mount. Resolve which of the three, then start, retarget, or mount.
Docker Compose: bind: address already in use and Port Conflicts
A published port is a host socket, and two projects cannot own it. How to find the real owner, why an override file merged instead of replacing, and how.
Docker Buildx: Building Multi-Architecture Images (AMD64 & ARM64) Explained
One tag, several architectures: the driver that supports it, QEMU versus cross-compilation, registry cache, and reading the manifest list.
More in Docker
All Docker guidesThe guides filed next to this one in Docker, in library order.