What the message looks like
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)Common causes
- Apache, another nginx instance or a panel service (Plesk, cPanel) already listens on port 80 or 443.
- nginx is already running and was started a second time instead of reloaded.
- A Docker container publishes the same port, e.g.
-p 80:80. - A stale nginx master process survived a crash or a bad restart.
- Two services were set to the same
listenaddress and port in your own configuration.
Check
- Who listens on port 80 and 443?
ss -ltnp | grep -E ':(80|443) ' - Is the configuration valid? (a port conflict only shows up on start)
nginx -t - Look for leftover nginx processes
ps aux | grep '[n]ginx' - Containers that publish ports
docker ps --format '{{.Names}} {{.Ports}}'
Fix
- Stop and disable the other service if it should not run:
systemctl disable --now apache2. - If nginx itself is running, use
systemctl reload nginxinstead of starting it again. - Kill only a clearly stale master process, then start the service:
pkill nginx; systemctl start nginx. - Move one of the services to another port, or bind each to its own IP address:
listen 203.0.113.10:80;. - On a server with a panel, change the setting in the panel and do not start a second nginx by hand.
Typical scenario
You install nginx on an Ubuntu server where phpMyAdmin or another package quietly pulled in Apache earlier. The install ends with "nginx.service failed", and journalctl -xeu nginx shows the bind() line with error 98. Nothing is broken: Apache simply got port 80 first. Before you touch any configuration, run systemctl status apache2 to see whether a second web server is active.
FAQ
nginx -t says OK but nginx still does not start. Why?
nginx -t checks the syntax and files, but it does not occupy the ports. A port conflict only appears when nginx really starts, so always read the output of ss -ltnp too.
Can two services share port 80?
Only if they listen on different IP addresses. For the same address and port, one of them has to move or sit behind the other as a reverse proxy.
Why does apt install nginx report a failure although the package is installed?
On Debian and Ubuntu the package starts the service right after installing. If port 80 is taken at that moment, only that start fails; the files are installed anyway. Once the conflict is resolved, a plain systemctl start nginx brings nginx up.
Does the error only occur on port 80?
No. The message always names the affected address and port, so it can just as well be 443 or any other listen port. Binding a port below 1024 without root rights gives error 13 (Permission denied), not 98, so the code in brackets tells you which problem you have.
Is a duplicate listen 80; in two server blocks the trigger?
Usually not. Several server blocks may share a port; nginx picks one by server_name. A duplicate default_server on the same port fails the config test with a different message. Error 98 only appears when a foreign process already holds the port.