[nginx] open "/usr/local/var/run/nginx.pid" failed AND nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)

System : ios
 
nginx -s stop execution error
 
open "/usr/local/var/run/nginx.pid" failed
This file does not exist, the file record number is actually the id of the process, the role of this file is to prevent the start of multiple process copies.
 
General solution
sudo nginx -c /usr/local/etc/nginx/nginx.conf // Specify a configuration file
 
 
I ca n’t solve it but add an error
nginx: [emerg] bind() to 0.0.0.0:8080 failed (48: Address already in use)
 
View nginx process
ps -ef | grep nginx
 
View services occupying port 8080
lsof -i:8080
Seeing that there are node and chrome, seeing Node remembered that a dev service was started locally, which is localhost: 8080 occupying port 8080
Stop this local localhost: 8080 service
 
Run sudo nginx -c /usr/local/etc/nginx/nginx.conf again and no error will be reported
 
Restart nginx again
  • nginx -s stop; Stop suod if prompted without permission
  • nignx start
Check the pid file and nginx process, everything is normal
 
 

Guess you like

Origin www.cnblogs.com/minnie-huang/p/12721877.html