Understanding the Error
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Another process is using port 80 or 443.
Find What's Using the Port
# Find process
sudo lsof -i :80
sudo lsof -i :443
sudo netstat -tlnp | grep -E ":80|:443"
sudo ss -tlnp | grep -E ":80|:443"
Common Culprits
1. Apache Already Running
sudo systemctl stop apache2
sudo systemctl disable apache2 # Prevent on boot
sudo systemctl start nginx
2. Old Nginx Process
sudo pkill nginx
sudo systemctl start nginx
3. Other Web Servers (Lighttpd, Caddy, Tomcat)
sudo systemctl stop lighttpd
sudo systemctl stop tomcat
4. Docker Container Exposing Port
docker ps
docker stop container_name
Force Kill Process
# Kill by PID
sudo kill -9 PID
# Kill by port
sudo fuser -k 80/tcp
sudo fuser -k 443/tcp
Nginx Already Running But Not Responding
# Check if nginx processes exist
ps aux | grep nginx
# Graceful restart
sudo nginx -s reload
# Full stop and start
sudo nginx -s stop
sudo systemctl start nginx
IPv6 vs IPv4 Conflict
You may have both listening on different addresses:
# Use specific IP instead of all
listen 192.168.1.100:80;
# Instead of
listen 80;
Check for Zombie Processes
ps aux | grep defunct
# Reboot if needed to clear
After killing the conflicting process, Nginx should start normally.