LoginSignup
0

posted at

updated at

【Windows, Mac】address already in use :3000 対応 「プロセスを見つけて強制終了する」を1コマンドで

はじめに

プロセスのIDを取得して、それをkillするのを1つにまとめている形です。
強制終了させるコマンドなので、用法用量にはご注意願います。

Windows(コマンドプロンプト)

for /f "tokens=5" %a in ('netstat -ano ^| findstr :3000') do taskkill /F /PID %a

ついでに powershell

foreach ($processId in (Get-NetTCPConnection -LocalPort 3000).OwningProcess) {
    taskkill /pid $processId /f
}

Mac (といっていいのか...)

lsof -i tcp:3000 | awk 'NR>1 {print $2}' | xargs kill

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
What you can do with signing up
0