NETWORK ENGINEER BLOG

Tips and Reviews for Engineers

CentOS で特定ポートで実行されているプロセスを強制終了する

CentOS 6.3 で WebGoat を起動しようとすると以下のエラーが出力されました。

***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

ポート 8080 使用されているようです。
使用しているプロセスは以下のコマンドで確認できます。

[root@hostname ~]# lsof -i:8080
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    16915 root   26u  IPv6  53443      0t0  TCP *:webcache (LISTEN)

Java の webcache が使用しているようです。
以下のコマンドで強制終了します。

[root@hostname ~]# kill $(lsof -t -i:8080)

もしくは、

[root@hostname ~]# kill -9 $(lsof -t -i:8080)

再度ポート 8080 の使用状況を確認します。

[root@hostname ~]# lsof -i:8080

正常に終了できていれば、表示されなくなります。

参考書籍

以上