Docker "port is already allocated": identify the host-port owner
A requested host address, protocol, and port already has a listener; inspect existing containers and processes before replacing the owner or choosing another host port.
Scope: Docker Engine or Desktop failing to bind a published TCP or UDP host port. Use docker ps -a --filter publish=<port>, docker port for a known container, and docker compose ps/config to inspect the resolved mapping. If Docker owns no matching port, use the operating system's trusted listener tool to identify the PID and process. Remember that HOST_PORT:CONTAINER_PORT puts the host port on the left.
After identifying the owner, normally stop or replace an intentional old container, or select a conflict-free host port while keeping the right side equal to the port where the application listens. TCP and UDP bindings are separate.
Do not kill an unknown PID or run docker rm -f before checking service impact, mounts, volumes, and writable data. Publishing without a host address commonly exposes the port on every interface; bind to 127.0.0.1 when only the host should reach it.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Docker Documentation — Docker Desktop troubleshooting / port already allocated ↗Revision 9395fc26fa18 · Apache-2.0 and attribution · reviewed snapshot SHA-256 (raw upstream page not redistributed)