LoginSignup
58

More than 5 years have passed since last update.

他プロセスがポートを占有してhttpdを再起動できない

Posted at

現象

httpdを再起動しようとすると、Address already in useと言われ再起動できない。

$ sudo /etc/init.d/httpd restart
httpd を停止                                               [  OK  ]
httpd を起動中: (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
                                                           [失敗]

環境

$ httpd -v
Server version: Apache/2.2.29 (Unix)
Server built:   Mar 12 2015 03:50:17

原因

httpdが異常終了する等して古いhttpdプロセスが残っていることが原因。

対策

lsofコマンドで古いプロセスを表示し、killすればよい。

$ sudo lsof -i | grep http
httpd    27512   apache    4u  IPv6  90360      0t0  TCP *:http (LISTEN)
httpd    27520   apache    4u  IPv6  90360      0t0  TCP *:http (LISTEN)

27512, 27520のidをもつプロセスが残っていることが分かる。

$ sudo kill -9 27512
$ sudo kill -9 27520

これで起動するようになる。

$ sudo /etc/init.d/httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
58