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.
Answers
Max Hoffmann
7 months ago
Rating
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:
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:
After removing Apache, restart Nginx:
Verify that ports 80 and 81 are now available for Nginx:
This should resolve the port conflict and allow Nginx to start successfully.