Skip to content
FR
  1. LuzineDebug
  2. Docker & DevOps
  3. Error response from daemon: driver failed progra…
Docker & DevOps Beginner ≈ 5 min to fix

Fix "Bind for 0.0.0.0:8080 failed: port is already allocated" (Docker)

Error message
Error response from daemon: driver failed programming external connectivity on endpoint web (3f1c9a2b7d4e): Bind for 0.0.0.0:8080 failed: port is already allocated
  • Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use
  • Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8080 -> 0.0.0.0:0: listen tcp 0.0.0.0:8080: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
  • Error: listen EADDRINUSE: address already in use :::3000
  • OSError: [Errno 98] Address already in use
  • Only one usage of each socket address (protocol/network address/port) is normally permitted.
In short

The host port you publish with -p 8080:80 is already taken, by another container or by a local program. Find who holds it (docker ps, lsof, Get-NetTCPConnection), stop it, or publish on another port, for example -p 8081:80.

Be the first to confirm this fix

What this error means

Publishing a port (-p 8080:80 or ports: in Compose) asks Docker to listen on host port 8080 and forward to the container. A TCP port can only be listened on by one process at a time on a given address. "port is already allocated" means Docker already assigned it to another container; "address already in use" (EADDRINUSE) comes from the operating system, when a process outside Docker (Node server, Apache, local MySQL…) is already listening. The container is created but does not start.

Common causes

  1. Another container already publishes this port: often an old docker compose up from another project, or a container with a restart: always policy that came back up.
  2. A local service listens on the port: a dev server (npm run dev, php artisan serve), Apache/Nginx, MySQL or PostgreSQL installed on the machine.
  3. Same port published twice in the same compose.yaml, or two replicas of a service with a fixed host port.
  4. Windows: port range reserved by Hyper-V/WSL (WinNAT). The error then says "forbidden by its access permissions" even though no program is listening.
  5. Ghost Docker proxy: after a crash, the daemon keeps the port reserved until it restarts.

Step-by-step fix

  1. Find the container publishing this port

    List containers (including stopped ones) that publish port 8080. If one shows up, that is the culprit.

    bash
    docker ps -a --filter "publish=8080"
    docker ps --format "table {{.Names}}\t{{.Ports}}"
  2. Stop that container

    Stop it, or stop the whole Compose project it belongs to from its folder. docker compose down removes the containers but keeps the volumes (without -v).

    bash
    docker stop <container_name>
    # or, from the other project's folder
    docker compose down
  3. Linux / macOS: find the local process

    If no container shows up, a system program is listening. lsof gives the PID; on Linux, ss works too. sudo is needed to see other users’ processes.

    bash
    sudo lsof -nP -iTCP:8080 -sTCP:LISTEN
    # Linux alternative
    sudo ss -ltnp 'sport = :8080'
    # then stop it gracefully
    kill <PID>
  4. Windows: find the local process

    In PowerShell, get the listening PID and then the program name. netstat -ano gives the same information in the classic command prompt.

    powershell
    $p = (Get-NetTCPConnection -LocalPort 8080 -State Listen).OwningProcess
    Get-Process -Id $p
    Stop-Process -Id $p
    # cmd alternative: netstat -ano | findstr :8080
  5. Or publish on another port

    If you want to keep the other service, only change the host port (left side). An environment variable avoids conflicts between developers.

    yaml
    services:
      web:
        image: nginx:1.27
        ports:
          - "${APP_PORT:-8081}:80"
  6. Windows: check reserved ports

    If nothing is listening but the error persists, look at the ranges excluded by Windows. Restarting the WinNAT service (admin PowerShell) often frees the range; otherwise pick a port outside those ranges.

    powershell
    netsh interface ipv4 show excludedportrange protocol=tcp
    net stop winnat
    net start winnat
  7. Restart Docker as a last resort

    If the port stays reserved while no container or process uses it, restart the daemon (Linux) or Docker Desktop (macOS/Windows).

    bash
    sudo systemctl restart docker

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • Make ports configurable (${APP_PORT:-8080}:80) and document them in .env.example.
  • Stop your projects with docker compose down instead of closing the terminal, and avoid restart: always in development.
  • Only publish what must be reachable from the host: internal services (database, Redis) talk over the Compose network without ports:.

Frequently asked questions

How do I find which program uses port 8080?

On Linux and macOS: sudo lsof -nP -iTCP:8080 -sTCP:LISTEN. On Windows: Get-NetTCPConnection -LocalPort 8080 -State Listen then Get-Process -Id <PID>.

What is the difference between "port is already allocated" and "address already in use"?

The first comes from Docker: another container already has that port. The second comes from the OS: a process, Docker or not, is already listening on that address.

Can two containers use the same port?

Yes inside (each has its own network), but not the same published host port. Publish them on different host ports or put a reverse proxy in front.

Useful tools for this error

More Docker & DevOps errors

All Docker & DevOps errors →