0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsで指定したポートを利用しているプロセスを終了する方法

0
Posted at

はじめに

Web開発などで「Port 3000 is already in use」といったエラーが発生した際、対象のポートを占有しているプロセスを特定して強制終了する手順をまとめました。

手順

netstatfindstr を利用し、対象のプロセスID(PID)を特定します。出力結果の一番右の列に表示されている数値が PID です。

netstat -ano | findstr :<ポート番号>

サンプル:

C:\Users\hnaka>netstat -ano | findstr :3000
  TCP         0.0.0.0:3000           0.0.0.0:0              LISTENING       14028
  TCP         127.0.0.1:3000         127.0.0.1:54658        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54664        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54669        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54670        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54671        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54672        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54673        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54681        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54682        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54683        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54684        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54685        TIME_WAIT       0
  TCP         127.0.0.1:3000         127.0.0.1:54686        TIME_WAIT       0
  TCP         [::]:3000              [::]:0                 LISTENING       14028

特定したプロセスを強制終了します。

taskkill /PID PID番号 /F

サンプル:

C:\Users\hnaka>>taskkill /PID 9844 /F
成功: PID 9844 のプロセスは強制終了されました。

環境

  • Microsoft Windows [Version 10.0.26100.8037]
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?