← Back to all fixes

Port is already in use when starting container

The Issue

`docker run -p 3000:3000 myapp` fails: `Bind for 0.0.0.0:3000 failed: port is already allocated`

Root Cause

Another process (or another container) is already listening on host port 3000.

How to Fix
  1. Find what is using the port: `sudo ss -tlnp | grep 3000` or `lsof -i :3000`
  2. Stop the conflicting process or container
  3. Or map to a different host port: `docker run -p 3001:3000 myapp` (host:container)
  4. List running containers and their ports: `docker ps --format "table {{.Names}} {{.Ports}}"`