使用中のポートとプロセスを調べる(Windows・macOS・Linux 対応、停止はしない)
Port and process inspector for Windows, macOS and Linux (never kills)
待ち受け中の TCP・UDP ポートと、それを使っているプロセス名・PID を一覧にし、指定したポートを誰が使っているかを調べます。プロセスは止めず、止める場合のコマンドを表示するだけです。
できること
「ポートがすでに使われています(address already in use)」のエラーの原因を調べます。
- 待ち受け中の TCP ポートと使用中の UDP ポートを、アドレス・ポート番号・PID・プロセス名つきで一覧表示
--port 3000のように指定すると、そのポートを使っているプロセスだけを表示- Windows は
netstat -anoとtasklist、macOS はlsof、Linux はss(なければlsof、netstat)を使用 - 止めたい場合に使えるコマンド(
taskkill /PID …やkill …)を表示。システムのプロセスには止めないよう注意を表示 - 他の PC で取ったコマンド出力をファイルから読み込んで解析することも可能
- JSON でも出力
使い方
python scripts/ports.py --port 3000
python scripts/ports.py --proto tcp
エージェントに「3000 番ポートを何が使っているか調べて」と頼むと、プロセスの正体と安全な対処法(アプリを普通に終了する、別のポートを使うなど)を説明します。Claude・Codex・Hermes Agent・Cursor で使えます。
必要な環境
- Python 3(標準ライブラリのみ)
- OS 標準のコマンド(Windows: netstat・tasklist、macOS: lsof、Linux: ss・lsof・netstat のいずれか)
注意点
- プロセスを停止することはありません。停止するかどうかは利用者が決めます。
- 管理者権限がないと、macOS や Linux では他のユーザーのプロセスが表示されないことがあります。
- WSL2 や Docker Desktop を使っている場合、転送用のプロセス名が表示されることがあります。
English description
Lists listening TCP and UDP ports with the owning PID and process name, and finds what holds a given port. It never stops anything; it only prints the command you could run.
What it does
Finds the cause of "address already in use" errors.
- Lists listening TCP ports and bound UDP ports with address, port, PID and process name
--port 3000shows only the process holding that port- Uses
netstat -anoandtaskliston Windows,lsofon macOS, andsson Linux (falling back tolsofornetstat) - Prints the command you could run to stop it (
taskkill /PID ...orkill ...), with a warning for system processes - Can parse saved command output from another machine
- JSON output
How to use
python scripts/ports.py --port 3000
python scripts/ports.py --proto tcp
Ask the agent "what is using port 3000?" and it explains what the process is and the safest fix (quit the app normally, use another port, and so on). Works with Claude, Codex, Hermes Agent and Cursor.
Requirements
- Python 3 (standard library only)
- Built-in OS tools (Windows: netstat and tasklist; macOS: lsof; Linux: one of ss, lsof or netstat)
Caveats
- It never stops a process; whether to stop one is your decision.
- Without admin or root rights, macOS and Linux may hide other users' processes.
- With WSL2 or Docker Desktop, a port-forwarding process may be shown as the owner.
インストール方法
- ダウンロードしたZIPを展開します(中に
port-process-inspector/フォルダとSKILL.mdがあります)。 - フォルダごと、使うエージェントのスキル置き場にコピーします。
- Claude:
~/.claude/skills/(プロジェクト単位なら.claude/skills/) - Hermes Agent:
~/.hermes/skills/ - Codex:
~/.agents/skills//Cursor:~/.cursor/skills/ - Claude アプリ(claude.ai):「カスタマイズ → スキル」からZIPをアップロード
- Claude:
- エージェントを再起動し、スキル一覧に表示されることを確認します。
出品者
Skills that make everyday developer work faster and safer: Git, testing, APIs and security.
出品スキル 8 件