Docker Compose Port Already Allocated Fix

A port allocation error means Docker cannot bind the host port requested in docker-compose.yml. Find what owns the port before changing random service config.

Symptoms

  • docker compose up fails with bind: address already in use.
  • A service exits immediately after container creation.
  • Changing container ports does not fix the host port conflict.

Likely causes

  • Another container already maps the same host port.
  • A local service such as Nginx, Apache, PostgreSQL or MySQL is running on that port.
  • The compose file maps the same host port twice.

Fix steps

  1. Run docker ps and check published ports.
  2. Use ss -ltnp or lsof -i to find local processes.
  3. Change the host-side port, not the container-side port, when you only need local access.

Verify the fix

  • Run docker compose config to inspect final merged ports.
  • Start the stack with docker compose up -d.
  • Open docker compose logs -f for the affected service.

FAQ

Which side is the host port?

In 8080:80, 8080 is the host port and 80 is the container port.

Can I remove the ports mapping?

Yes, if the service only needs internal network access from other containers.

Related tools and guides

Last updated: May 18, 2026