Judging from the output information, multiple Nginx processes have been bound and listened to port 80 (i.e.*http
), which means that Nginx is already running and occupies the HTTP port. This is why the new Nginx instance fails to start because the port is already occupied.
To resolve this problem, you can follow these steps:
1. Confirm that Nginx is running
I have seen Nginx listening on port 80. If you really don't need to start a new Nginx instance, just continue to use the existing instance. Otherwise, continue with the following steps.
2. Kill existing Nginx processes
If you intend to restart Nginx, you need to stop or kill the running Nginx process first.
First try to stop the Nginx service gracefully:
sudo systemctl stop nginx
ifsystemctl
The stop command did not succeed (or Nginx was started manually), you can usekill
Command to terminate the process:
sudo kill -9 8507 20453 20454 20455 20456 20457 20458 20459 20460
These are the process IDs that run Nginx and need to be replaced with the process IDs you actually see.
3. Confirm that all Nginx processes have stopped
Use the following command to confirm that no Nginx process is still running:
ps aux | grep nginx
If there are no Nginx processes in the output, they have stopped.
4. Restart Nginx
Now, try restarting Nginx:
sudo systemctl start nginx
5. Check Nginx status
Confirm that Nginx has been started successfully and no port conflicts have been encountered:
sudo systemctl status nginx
Through these steps, the problem of Nginx port being occupied should be solved. If you want to run multiple Nginx instances at the same time, make sure that the ports they listen for are different.
This is all about this article about the solution to the Nginx port occupied (systemctl restart nginx failed). For more related content about Nginx port occupied, please search for my previous article or continue browsing the related articles below. I hope everyone will support me in the future!