Nginx Won't Start: bind() to 0.0.0.0:80 Failed (Address Already in Use)
Nginx refuses to start with 'bind() to 0.0.0.0:80 failed (Address already in use)'. Something else already owns port 80 — often Apache, or another Nginx. Here's how to find and clear it.
Nginx fails to start and the log says:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Only one program can listen on a given port at a time. Nginx wants port 80 (and usually 443), but this error means something already has it. Nginx can't share, so it refuses to start. The whole job is to find what's holding the port and deal with it.
Step 1: Find what's on the port
List whatever is listening on 80:
sudo ss -ltnp | grep ':80 ' # shows the process name and PID holding port 80
You'll usually see one of three culprits:
apache2/httpd— a web server installed by default or by a package, competing for 80.- Another
nginx— an old instance that didn't stop cleanly, or a stray master process. - Some app bound directly to 80.
Step 2: Stop the other service
If it's Apache and you meant to use Nginx, stop and disable it:
sudo systemctl stop apache2
sudo systemctl disable apache2 # keep it from grabbing 80 on next boot
If it's a leftover Nginx process rather than a second server, stop the service cleanly first:
sudo systemctl stop nginx
sudo pkill -f nginx # only if a stray master lingers after stop
Step 3: Start Nginx (after testing config)
sudo nginx -t # catch config errors before starting
sudo systemctl start nginx
Watch out: a duplicate listen in your own config
If nothing else owns the port, you may have two server blocks both listen 80 for the same address — Nginx collides with itself. Grep your config and remove the duplicate:
grep -rn 'listen 80' /etc/nginx/
"Address already in use" is never mysterious: exactly one other thing holds the port. Identify it with
ss -ltnpfirst — don't guess, and don't just keep restarting Nginx.
The checklist
- Something else owns port 80 — Nginx can't share it.
sudo ss -ltnp | grep ':80 'to name the process.- Apache?
systemctl stop apache2 && systemctl disable apache2. Stray nginx? stop it cleanly. - Still failing? Grep for a duplicate
listen 80in your own config.
Stop reading, start building
This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.