📝

使用しているポートのプロセスを調べる方法

2021/04/05に公開

だれ?ポート使っているのは?

って思うときありますよね。そんなときは lsofコマンド。実は、Apache が起動しなくて何かしたっけ?と30分位はまったのでいつもの自分メモ。

あれ?怒られるw

Apache がなにをやっても起動しなく出ていたログ。誰か(プロセス)がすでにポートを使用しているという風に怒られ Apache が起動できません。

command
# /etc/init.d/httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
                                                           [FAILED]

おまえか!!

と、lsofコマンドを実行してみる。どうやら nginx が起動していたでござるった。
そりゃ Address already in use と怒られますね。

command
$ lsof -i | grep http
nginx     2945         root    7u  IPv4  15378      0t0  TCP *:http (LISTEN)
nginx     2946          git    7u  IPv4  15378      0t0  TCP *:http (LISTEN)
GitHubで編集を提案

Discussion