Home / Localhost / Docker port already allocated

Docker: Bind for 0.0.0.0:8080 failed: port is already allocated

Fix "port is already allocated" in Docker and Docker Compose: find the container or program that holds the port and free it.

This error appears when Docker tries to publish a container port on your computer and that port is already taken, by another container or by a normal program. Find who holds it, stop it, or publish on a different port.

What to do, step by step

  1. Read the port in the error, such as 8080.
  2. List running containers and look at the PORTS column: docker ps.
  3. If a container holds the port, stop it with docker stop name, or run docker compose down in the project that started it.
  4. If no container holds it, a normal program does. Find it with lsof -i :8080 (macOS, Linux) or netstat -ano | findstr :8080 (Windows).
  5. Or change the left number in your ports line, for example "8081:80". The right number stays the same.

Commands you can copy

List containers and their ports
docker ps
Stop one container
docker stop container-name
Stop and remove a Compose project
docker compose down
macOS or Linux: find a normal program on a port
lsof -i :8080
Windows: find a normal program on a port
netstat -ano | findstr :8080

Other causes to check

Port shows free but the error remains
An old container may be stopped but not removed. Run docker ps -a, then docker rm name. Restarting Docker Desktop also clears stuck port forwards.
MySQL on 3306 fails
A MySQL server is probably installed on your computer already. Publish the container on "3307:3306" and connect to port 3307.
Windows: port is excluded by Hyper-V
Windows reserves some ranges. Check with netsh interface ipv4 show excludedportrange protocol=tcp and choose a port outside them.
Two Compose projects use the same port
Give each project its own left-hand port number.

Questions about Docker port already allocated

What does the port mapping 8080:80 mean?
The left number is the port on your computer. The right number is the port inside the container. Change the left one to avoid a clash.
How do I stop all containers?
Run docker stop with the names from docker ps, or docker compose down inside a project folder. Check what each container does before stopping it.
Why is the port taken after I stopped my app?
A different container or a background program may use it. Check docker ps -a and the port commands on this page.

Updated 2026-10-11

Free tools that help

Config generators for this

Related pages