Nginx – Error: ‘bind() to 0.0.0.0:80 failed’

Recently, I’ve encountered an issue when starting Nginx. Ports 80 and 81 are already being listened to by another process, but I can’t figure out which one. I haven’t changed the Nginx configuration, and it has been checked for errors, but when I attempt to start Nginx, I get the following error:

		
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Unknown error) nginx: [emerg] bind() to [::]:80 failed (98: Unknown error) nginx: [emerg] bind() to 0.0.0.0:81 failed (98: Unknown error) nginx: [emerg] still could not bind()

I tried to fix this by:

1. Restarting the system.
2. Stopping and restarting Nginx.
3. Terminating processes that might be using ports 80 and 81, using fuser and killall.
4. Checking the ports with netstat and lsof.
However, the issue remains unresolved.

Tom Dupuis

7 months ago

1 answer

96 views

Rating

00
Answer

Answers

Max Hoffmann

7 months ago

Rating

00

The issue you're facing might be caused by Apache being installed and running on your system, as it also uses ports 80 and 81, leading to a conflict with Nginx. Both servers cannot bind to the same ports.

To resolve the issue, follow these steps:

Check if Apache is installed and running:

		
sudo systemctl status apache2

If Apache is not installed, I'm afraid I can't help further.

If Apache is installed, you can remove it along with its components using the following command:

		
sudo apt-get remove --purge apache2*

After removing Apache, restart Nginx:

		
sudo systemctl restart nginx

Verify that ports 80 and 81 are now available for Nginx:

		
sudo netstat -tulpn | grep :80 sudo lsof -i :80

This should resolve the port conflict and allow Nginx to start successfully.

Reply