Docker Port Is Already Allocated: Find the Conflicting Process Without Restarting Your Machine

You run docker run -p 8080:80 nginx or docker compose up, and instead of a running container you get this:

docker: Error response from daemon: driver failed programming external connectivity on endpoint web (a1b2c3...): Bind for 0.0.0.0:8080 failed: port is already allocated.

The usual reaction is to restart Docker, then the laptop, and hope it goes away. It often does, which is why the habit sticks. But a reboot is the slowest and least informative fix. It hides which process held the port, so the problem returns next week.

This guide shows how to find exactly what is holding the port, on Linux, macOS and Windows, and how to fix it without rebooting. It also covers how to stop it from recurring.

Quick answer: run docker ps --filter "publish=8080" first. If a container shows up, stop it or remap your port. If nothing shows up, a non-Docker process owns the port. Find it with ss, lsof or netstat, depending on your operating system.

What "port is already allocated" actually means

When you publish a port with -p 8080:80 (or ports: in Compose), Docker sets up a forwarding rule from a port on the host to a port inside the container. The official describes it this way: maps port 8080 on the Docker host to port 80 in the container.