Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Windows 與 Linux 查詢埠號 80 佔用情況並終止進程完整指令

編輯:系統常見問題解答

需確認誰佔用了 TCP 80 埠 (常見衝突:IIS、Apache、Nginx、System 進程),Windows 用 netstat + tasklist/taskkill,Linux 用 netstat/ss + lsof/kill。

Windows

rem 1. 查詢 80 埠佔用 PID
netstat -aon | findstr ":80"

rem 輸出範例:
rem TCP    0.0.0.0:80    0.0.0.0:0    LISTENING    1688

rem 2. 依 PID 查詢進程名稱
tasklist | findstr "1688"

rem 輸出範例:
rem inetinfo.exe    1688    Console    0    2,800 K

rem 3. 終止進程 (需管理員)
taskkill /f /pid 1688

Linux

# 方法一: netstat (傳統)
netstat -anp | grep ":80"

# 方法二: ss (現代、更快)
ss -ltnp | grep ":80"

# 方法三: lsof (最直觀)
lsof -i:80

# 輸出範例:
# COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
# nginx   1234 root    6u  IPv4  12345      0t0  TCP *:80 (LISTEN)

# 終止進程
kill -9 1234

常見佔用 80 埠的服務

System (PID 4) 佔用 80 埠怎麼辦?

rem 查看 HTTP.sys 保留的 URL
netsh http show urlacl

rem 刪除特定保留 (視需求)
netsh http delete urlacl url=https://+:80/

或停用不需要的服務 (WinRM: winrm delete winrm/config/listener?Address=*+Transport=HTTP)。

Copyright © Windows教程網 All Rights Reserved
作業系統進程名稱對應服務
Windowsinetinfo.exeIIS (WWW 服務)
Windowshttpd.exeApache HTTP Server
Windowsnginx.exeNginx
WindowsSystem (PID 4)HTTP.sys 核心驅動 (WinRM, BranchCache, IIS 共用)
LinuxnginxNginx
Linuxhttpd / apache2Apache
LinuxlighttpdLighttpd