How to Fix ‘Bind for 0.0.0.0:80 Failed’ Error in Docker
When working with Docker, especially on Windows or macOS, you might hit this frustrating error:
Bind for 0.0.0.0:80 failed: port is already allocated.
This usually means something else is already using that port. Let’s explore how to fix Docker Bind for 0.0.0.0:80 Failed — with a clear example.
What Causes the Error?
Docker containers try to bind a container port (e.g., 80) to a host port (0.0.0.0:80). If that port is already in use on your machine, Docker can’t bind it, and you’ll get this error.
Example That Triggers the Error
Run another container (or another process) using host port 80:
docker run -d --name temp-nginx -p 80:80 nginx
- This container will occupy port 80 on the host
- It runs in the background (-d) so it does not occupy the terminal
Let’s say you have a basic Dockerfile running a Flask app:
app.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello from Docker!"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY app.py .
RUN pip install flask
CMD ["python", "app.py"]
Run this container:
docker build -t flask-port80 .
docker run -p 80:80 flask-port80
You might get:
docker: Error response from daemon: driver failed programming external connectivity on endpoint ...
Bind for 0.0.0.0:80 failed: port is already allocated.

How To Fix Docker Bind for 0.0.0.0:80 Failed
1. Check if Port 80 Is Already in Use
On Linux/macOS:
sudo lsof -i :80
On Windows PowerShell:
netstat -aon | findstr :80
Then find the PID, and:
tasklist | findstr <PID>
2. Free Port 80 (Optional)
You can stop the service occupying the port, or:
- On Windows, you might need to stop services like IIS, W3SVC, or Hyper-V using port 80.
- Or simply restart Docker Desktop and try again.
3. Use a Different Host Port
If you just want to avoid the conflict, map to a different host port:
docker run -p 8080:80 flask-port80
Now your container still listens on port 80 inside, but you access it at:
http://localhost:8080
4. Use Docker Compose With Custom Port
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- "8080:80"
Run:
docker-compose up
Summary
| Solution | When to Use |
Change host port (-p 8080:80) | Quick workaround to avoid port conflicts |
| Kill the existing process | You control the host and want to reclaim port 80 |
| Use Docker Compose | Managing multiple containers or custom config |
| Use Linux port mapping tools | Advanced use cases (e.g., IPTables, firewalld) |
The 'Docker Bind for 0.0.0.0:80 failed' error is common, but also easy to solve once you know the root cause. Most of the time, it just means another process (or container) already owns port 80. Try changing ports or checking running processes — and you’re good to go!
This is the end of the How to Fix ‘Bind for 0.0.0.0:80 Failed’ Error in Docker.
You can read more useful articles like How To Fix Docker Build Cache Not Updating.
Follow us for the more helpful posts!
We hope this is a useful post for you.