bind() failed (98: Address already in use) 🐧 Linux

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

Nginx (or another server) can’t listen on the port because another process already holds it — often Apache, another Nginx, or a stale master process.

Seen on: Linux

Meaning

Only one process can bind a given IP:port. On fresh servers Apache is often pre-installed on port 80; a second nginx started by hand, a Docker container publishing 80, or an IPv6 listen duplicated in two server blocks causes the same message.

Common causes

  • Apache/another web server running on the port
  • Old nginx master process still running
  • Docker container publishing the port
  • Duplicate listen directives (e.g. listen [::]:80 twice)

⚡ Quick fix

  1. Find the owner: sudo ss -ltnp 'sport = :80'
  2. Stop/disable the other service
  3. Remove duplicate listen lines, then nginx -t

Detailed fix by platform

Linux

  1. bash
    sudo ss -ltnp 'sport = :80'
    sudo systemctl disable --now apache2
    sudo nginx -t && sudo systemctl restart nginx

How to diagnose

  1. Owner — PID/program on the port
  2. Config — grep -rn 'listen' /etc/nginx/
  3. Containers — docker ps --format '{{.Ports}}'

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.