एरर समाधान · डेवलपर एरर

Docker "bind: address already in use" and "port is already allocated

Fix Docker "Bind for 0.0.0.0:80 failed: port is already allocated" and "address already in use": find the process or container holding the port and remap it.

Error messageBind for 0.0.0.0:80 failed: port is already allocated

लेखक: SiteDownCheck संपादकीय टीम · अपडेट: अक्टूबर 21, 2026 · 4 मिनट पढ़ने में

Docker publishes a container port by binding a port on the host. If something else already owns that host port, the bind fails and the container does not start. You will see one of two messages, depending on who owns the port:

docker: Error response from daemon: driver failed programming external connectivity on endpoint web:
Bind for 0.0.0.0:80 failed: port is already allocated.

Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use

"port is already allocated" usually means another Docker container (or a stale Docker network entry) holds it. "address already in use" usually means a normal host process, such as nginx, Apache or a dev server, is listening. Both are fixed the same way: find the owner, then stop it, or publish on a different host port.

Check in this order

  1. Is another container publishing the port? Run docker ps --format 'table {{.Names}}\t{{.Ports}}' and look for the port, including stopped-but-restarting containers.
  2. Is a host process listening? Use ss as shown below.
  3. Is a Compose project from another folder running? Containers from a different directory are easy to forget.
  4. Is it a leftover after a crash? If nothing owns the port but Docker still complains, restart the Docker daemon.

Find what owns the port

On Linux:

sudo ss -ltnp 'sport = :80'
sudo lsof -iTCP:80 -sTCP:LISTEN -n -P

On macOS use sudo lsof -iTCP:80 -sTCP:LISTEN -n -P. On Windows PowerShell:

Get-NetTCPConnection -LocalPort 80 -State Listen | Select-Object OwningProcess
Get-Process -Id <pid>

If the owner is a container, find it by published port:

docker ps --filter "publish=80"
docker ps -a --format '{{.ID}} {{.Names}} {{.Ports}}' | grep ':80->'

Fixes

Stop or remove the container that holds it

docker stop old-web && docker rm old-web
docker compose down

If the old container belongs to another project, docker compose ls lists running projects and their config files.

Stop the host service

A system web server on port 80 or 443 is the classic conflict when you run a containerized proxy:

sudo systemctl stop nginx apache2
sudo systemctl disable nginx   # only if you do not want it back at boot

Publish a different host port

The left number is the host port, the right is the container port. Only the left one needs to change:

docker run -d -p 8080:80 nginx
services:
  web:
    image: nginx
    ports:
      - "8080:80"

If a reverse proxy already owns 80 and 443, do not publish the app at all. Put it on the same Docker network as the proxy and let the proxy reach it by service name.

Bind to loopback only

If the service should not be reachable from outside, say so. This also avoids clashing with a service bound to another interface:

ports:
  - "127.0.0.1:5432:5432"

When nothing is listening but it still fails

Sometimes ss shows nothing, yet Docker reports the port as allocated. Common reasons:

  • A container is in a restart loop and grabs the port each time it comes up. docker ps -a shows Restarting.
  • The daemon's userland proxy was left behind after a crash. Restart Docker with sudo systemctl restart docker, then start your containers again.
  • A port range was reserved by the OS. On Windows with Hyper-V or WSL2, check netsh interface ipv4 show excludedportrange protocol=tcp; ranges listed there cannot be bound. Choose a port outside them.
  • IPv4 and IPv6 mismatch. Another process may hold [::]:80 while you bind 0.0.0.0:80. The ss output shows both families.

Verify from the outside

Once the container is up, confirm the port is really reachable, not just bound. From the host, curl -I http://localhost:8080. From the internet, use the पोर्ट चेकर on your public IP and port, and the वेबसाइट हेल्थ चेक for the full URL. A bound port with a firewall in front still looks closed from outside; see the Docker website down checklist.

The same conflict shows up in plain Node.js as EADDRINUSE.

अगले कदम

सामान्य प्रश्न

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

The first comes from Docker itself and usually means another container holds the port. The second comes from the operating system and means a host process is listening. The cure is the same: free the port or remap it.

Do I need to change the container port too?

No. In -p HOST:CONTAINER, only the host side must be free. Many containers can all listen on port 80 internally.

Why does it work after a reboot?

A reboot clears stale proxy processes and stops the conflicting service from starting first. Check boot order if the host's nginx or Apache starts before Docker and keeps winning the port.

Can two containers share one port?

Not on the same host IP and port. Use a reverse proxy that routes by hostname, or bind each container to a different host port or address.

Get notified when this fix updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.