nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginxを使っていて再起動しようとすると、なぜか再起動できないという事がありました。confファイルにNGなどはないです。 そこでエラーログをみてみるとエラーがりました
[c] cat /var/log/messages Apr 7 20:46:27 ik1-401-32566 nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Apr 7 20:46:27 ik1-401-32566 nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Apr 7 20:46:28 ik1-401-32566 nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Apr 7 20:46:28 ik1-401-32566 nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Apr 7 20:46:29 ik1-401-32566 nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) [/c]
この対処法になります
状況
nginxはApacheにリバースプロキシの設定をしていてApacheは起動状態となっています
原因
古いhttpdのプロセスが残っているのが原因みたいです
対処法
古いプロセスをkillすれば問題ないです
[c] sudo lsof -i | grep nginx nginx 14843 nginx 6u IPv4 243654 0t0 TCP *:http (LISTEN) nginx 14843 nginx 7u IPv4 243655 0t0 TCP *:https (LISTEN) [/c]
[c] sudo kill 14843 [/c]
等とプロセスをkillすれば再起動できます
