一 . 用netstat指令查看是端口占用情況
查看所有端口的占用情況
C:\Users\Administrator>netstat -ano
活動連接
協(xié)議 本地地址 外部地址 狀態(tài) PID
TCP 0.0.0.0:21 0.0.0.0:0 LISTENING 2228
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 740
TCP 0.0.0.0:389 0.0.0.0:0 LISTENING 3428
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:902 0.0.0.0:0 LISTENING 2496
TCP 0.0.0.0:912 0.0.0.0:0 LISTENING 2496
TCP 0.0.0.0:1689 0.0.0.0:0 LISTENING 3428
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 2612
TCP 0.0.0.0:3389 0.0.0.0:0 LISTENING 856
TCP 0.0.0.0:4444 0.0.0.0:0 LISTENING 3428
TCP 0.0.0.0:5985 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:8085 0.0.0.0:0 LISTENING 8044
TCP 0.0.0.0:47001 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:49664 0.0.0.0:0 LISTENING 476
TCP 0.0.0.0:49665 0.0.0.0:0 LISTENING 1012
TCP 0.0.0.0:49666 0.0.0.0:0 LISTENING 848
TCP 0.0.0.0:49667 0.0.0.0:0 LISTENING 1688
TCP 0.0.0.0:49668 0.0.0.0:0 LISTENING 2004
TCP 0.0.0.0:49669 0.0.0.0:0 LISTENING 600
TCP 0.0.0.0:49670 0.0.0.0:0 LISTENING 584
TCP 0.0.0.0:54021 0.0.0.0:0 LISTENING 3428
TCP 10.159.64.24:139 0.0.0.0:0 LISTENING 4
TCP 10.159.64.24:3389 10.159.44.100:45306 ESTABLISHED 856
TCP 10.159.64.24:54021 10.159.64.24:60248 ESTABLISHED 3428
TCP 10.159.64.24:60248 10.159.64.24:54021 ESTABLISHED 3428
TCP 127.0.0.1:7085 0.0.0.0:0 LISTENING 8044
TCP 127.0.0.1:54008 127.0.0.1:54009 ESTABLISHED 3428
TCP 127.0.0.1:54009 127.0.0.1:54008 ESTABLISHED 3428
TCP 127.0.0.1:54011 127.0.0.1:54012 ESTABLISHED 3428
TCP 127.0.0.1:54012 127.0.0.1:54011 ESTABLISHED 3428
TCP 127.0.0.1:54013 127.0.0.1:54014 ESTABLISHED 3428
TCP 127.0.0.1:54014 127.0.0.1:54013 ESTABLISHED 3428
TCP 127.0.0.1:54016 127.0.0.1:54017 ESTABLISHED 3428
TCP 127.0.0.1:54017 127.0.0.1:54016 ESTABLISHED 3428
TCP 127.0.0.1:54018 127.0.0.1:54019 ESTABLISHED 3428
TCP 127.0.0.1:54019 127.0.0.1:54018 ESTABLISHED 3428
TCP 127.0.0.1:54025 127.0.0.1:54026 ESTABLISHED 8044
TCP 127.0.0.1:54026 127.0.0.1:54025 ESTABLISHED 8044
TCP 192.168.58.1:139 0.0.0.0:0 LISTENING 4
TCP 192.168.195.1:139 0.0.0.0:0 LISTENING 4
TCP [::]:21 [::]:0 LISTENING 2228
TCP [::]:80 [::]:0 LISTENING 4
TCP [::]:135 [::]:0 LISTENING 740
TCP [::]:389 [::]:0 LISTENING 3428
TCP [::]:445 [::]:0 LISTENING 4
TCP [::]:1689 [::]:0 LISTENING 3428
TCP [::]:3306 [::]:0 LISTENING 2612
TCP [::]:3389 [::]:0 LISTENING 856
TCP [::]:4444 [::]:0 LISTENING 3428
TCP [::]:5985 [::]:0 LISTENING 4
TCP [::]:8085 [::]:0 LISTENING 8044
TCP [::]:47001 [::]:0 LISTENING 4
TCP [::]:49664 [::]:0 LISTENING 476
TCP [::]:49665 [::]:0 LISTENING 1012
TCP [::]:49666 [::]:0 LISTENING 848
TCP [::]:49667 [::]:0 LISTENING 1688
TCP [::]:49668 [::]:0 LISTENING 2004
TCP [::]:49669 [::]:0 LISTENING 600
TCP [::]:49670 [::]:0 LISTENING 584
TCP [::]:54021 [::]:0 LISTENING 3428
UDP 0.0.0.0:123 *:* 452
UDP 0.0.0.0:500 *:* 848
UDP 0.0.0.0:3389 *:* 856
UDP 0.0.0.0:4500 *:* 848
UDP 0.0.0.0:5050 *:* 452
UDP 0.0.0.0:5353 *:* 1120
UDP 0.0.0.0:5355 *:* 1120
UDP 10.159.64.24:137 *:* 4
UDP 10.159.64.24:138 *:* 4
UDP 10.159.64.24:1900 *:* 716
UDP 10.159.64.24:52841 *:* 716
UDP 127.0.0.1:1900 *:* 716
UDP 127.0.0.1:52844 *:* 716
UDP 192.168.58.1:137 *:* 4
UDP 192.168.58.1:138 *:* 4
UDP 192.168.58.1:1900 *:* 716
UDP 192.168.58.1:52843 *:* 716
UDP 192.168.195.1:137 *:* 4
UDP 192.168.195.1:138 *:* 4
UDP 192.168.195.1:1900 *:* 716
UDP 192.168.195.1:52842 *:* 716
UDP [::]:123 *:* 452
UDP [::]:500 *:* 848
UDP [::]:3389 *:* 856
UDP [::]:4500 *:* 848
UDP [::]:5353 *:* 1120
UDP [::]:5355 *:* 1120
UDP [::1]:1900 *:* 716
UDP [::1]:52840 *:* 716
UDP [fe80::557e:e741:6082:9989%4]:546 *:* 1012
UDP [fe80::557e:e741:6082:9989%4]:1900 *:* 716
UDP [fe80::557e:e741:6082:9989%4]:52839 *:* 716
UDP [fe80::e04c:f5c2:4a:3289%3]:1900 *:* 716
UDP [fe80::e04c:f5c2:4a:3289%3]:52838 *:* 716
命令格式:netstat [options]
-a表示顯示所有活動的TCP連接以及計算機監(jiān)聽的TCP和UDP端口。
-n表示只以數(shù)字形式顯示所有活動的TCP連接的地址和端口號。
-o表示顯示活動的TCP連接并包括每個連接的進程ID(PID)。
查看特定端口的占用情況(以80端口為例)
C:\Users\Administrator>netstat -aon|findstr 80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 0.0.0.0:8085 0.0.0.0:0 LISTENING 8044
TCP 127.0.0.1:7085 0.0.0.0:0 LISTENING 8044
TCP 127.0.0.1:54025 127.0.0.1:54026 ESTABLISHED 8044
TCP 127.0.0.1:54026 127.0.0.1:54025 ESTABLISHED 8044
TCP [::]:80 [::]:0 LISTENING 4
TCP [::]:8085 [::]:0 LISTENING 8044
UDP [fe80::557e:e741:6082:9989%4]:1900 *:* 716
UDP [fe80::557e:e741:6082:9989%4]:52839 *:* 716
UDP [fe80::e04c:f5c2:4a:3289%3]:1900 *:* 716
UDP [fe80::e04c:f5c2:4a:3289%3]:52838 *:* 716
在第2列可以找到,占用80端口的進程號為4。
二. 用tasklist指令查找進程號對應(yīng)的名稱
查找所有進程號對應(yīng)的名稱
C:\Users\Administrator>tasklist
映像名稱 PID 會話名 會話# 內(nèi)存使用
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 4 K
System 4 Services 0 140 K
smss.exe 260 Services 0 1,280 K
csrss.exe 368 Services 0 4,344 K
csrss.exe 456 Console 1 4,096 K
wininit.exe 476 Services 0 5,900 K
winlogon.exe 512 Console 1 8,456 K
services.exe 584 Services 0 13,848 K
lsass.exe 600 Services 0 16,572 K
svchost.exe 676 Services 0 26,880 K
svchost.exe 740 Services 0 24,716 K
svchost.exe 848 Services 0 140,064 K
svchost.exe 856 Services 0 50,948 K
svchost.exe 912 Services 0 32,872 K
dwm.exe 932 Console 1 29,708 K
LogonUI.exe 940 Console 1 41,764 K
svchost.exe 1012 Services 0 30,416 K
svchost.exe 452 Services 0 25,796 K
WUDFHost.exe 1032 Services 0 8,284 K
svchost.exe 1052 Services 0 18,176 K
svchost.exe 1120 Services 0 23,008 K
svchost.exe 1128 Services 0 7,252 K
svchost.exe 2004 Services 0 7,288 K
spoolsv.exe 1688 Services 0 16,612 K
svchost.exe 2144 Services 0 25,436 K
svchost.exe 2152 Services 0 10,592 K
svchost.exe 2184 Services 0 8,488 K
svchost.exe 2192 Services 0 19,312 K
svchost.exe 2228 Services 0 11,568 K
vmnat.exe 2252 Services 0 6,956 K
svchost.exe 2260 Services 0 11,440 K
MsMpEng.exe 2352 Services 0 154,116 K
vmnetdhcp.exe 2380 Services 0 11,216 K
vmware-usbarbitrator64.ex 2444 Services 0 10,000 K
vmware-authd.exe 2496 Services 0 13,440 K
mysqld.exe 2612 Services 0 26,688 K
csrss.exe 3864 RDP-Tcp#6 2 12,792 K
winlogon.exe 3924 RDP-Tcp#6 2 8,400 K
dwm.exe 3988 RDP-Tcp#6 2 128,360 K
rdpclip.exe 1220 RDP-Tcp#6 2 20,332 K
RuntimeBroker.exe 3612 RDP-Tcp#6 2 34,632 K
sihost.exe 3764 RDP-Tcp#6 2 22,676 K
svchost.exe 3080 RDP-Tcp#6 2 19,868 K
taskhostw.exe 1752 RDP-Tcp#6 2 20,804 K
explorer.exe 4024 RDP-Tcp#6 2 523,136 K
ChsIME.exe 1936 RDP-Tcp#6 2 9,064 K
ShellExperienceHost.exe 4308 RDP-Tcp#6 2 83,412 K
SearchUI.exe 4392 RDP-Tcp#6 2 47,184 K
ServerManager.exe 4700 RDP-Tcp#6 2 99,764 K
vmware-tray.exe 4936 RDP-Tcp#6 2 12,512 K
msdtc.exe 4792 Services 0 9,692 K
plmdeployer_prd_simple.ex 5008 RDP-Tcp#6 2 103,076 K
plmdeployer_prd_simple.ex 3776 RDP-Tcp#6 2 92,332 K
notepad.exe 1184 RDP-Tcp#6 2 14,124 K
dllhost.exe 3264 RDP-Tcp#6 2 9,140 K
plmdeployer_prd_simple.ex 2112 RDP-Tcp#6 2 93,160 K
svchost.exe 716 Services 0 6,892 K
mmc.exe 376 RDP-Tcp#6 2 11,144 K
mmc.exe 800 RDP-Tcp#6 2 17,328 K
taskhostw.exe 4352 RDP-Tcp#6 2 19,148 K
notepad.exe 724 RDP-Tcp#6 2 14,080 K
wordpad.exe 7576 RDP-Tcp#6 2 36,588 K
java.exe 3428 RDP-Tcp#6 2 372,520 K
cmd.exe 8088 RDP-Tcp#6 2 3,212 K
conhost.exe 3520 RDP-Tcp#6 2 15,196 K
java.exe 8044 RDP-Tcp#6 2 561,224 K
wordpad.exe 5724 RDP-Tcp#6 2 33,536 K
notepad.exe 5688 RDP-Tcp#6 2 15,676 K
git-bash.exe 4932 RDP-Tcp#6 2 5,164 K
mintty.exe 5348 RDP-Tcp#6 2 19,216 K
conhost.exe 8632 RDP-Tcp#6 2 11,716 K
bash.exe 9108 RDP-Tcp#6 2 9,644 K
git-bash.exe 5148 RDP-Tcp#6 2 5,104 K
mintty.exe 9084 RDP-Tcp#6 2 18,784 K
conhost.exe 8488 RDP-Tcp#6 2 11,724 K
bash.exe 4408 RDP-Tcp#6 2 9,588 K
git-bash.exe 756 RDP-Tcp#6 2 5,124 K
mintty.exe 2284 RDP-Tcp#6 2 18,220 K
conhost.exe 980 RDP-Tcp#6 2 11,676 K
bash.exe 5892 RDP-Tcp#6 2 9,580 K
notepad.exe 8272 RDP-Tcp#6 2 14,852 K
notepad.exe 3464 RDP-Tcp#6 2 14,436 K
cmd.exe 3636 RDP-Tcp#6 2 2,900 K
conhost.exe 8756 RDP-Tcp#6 2 14,972 K
notepad.exe 9036 RDP-Tcp#6 2 15,964 K
mmc.exe 7244 RDP-Tcp#6 2 13,036 K
ApplicationFrameHost.exe 5996 RDP-Tcp#6 2 24,204 K
SystemSettings.exe 6804 RDP-Tcp#6 2 57,788 K
MpCmdRun.exe 5948 Services 0 8,248 K
svchost.exe 5572 Services 0 6,228 K
tasklist.exe 6904 RDP-Tcp#6 2 8,080 K
WmiPrvSE.exe 3084 Services 0 8,688 K
查找所有特定進程號對應(yīng)的名稱(以進程4為例)
C:\Users\Administrator>tasklist|findstr 4
System Idle Process 0 Services 0 4 K
System 4 Services 0 140 K
csrss.exe 368 Services 0 4,340 K
csrss.exe 456 Console 1 4,096 K
wininit.exe 476 Services 0 5,900 K
winlogon.exe 512 Console 1 8,456 K
services.exe 584 Services 0 13,848 K
svchost.exe 740 Services 0 24,716 K
svchost.exe 848 Services 0 138,932 K
svchost.exe 856 Services 0 51,140 K
LogonUI.exe 940 Console 1 41,764 K
svchost.exe 1012 Services 0 30,456 K
svchost.exe 452 Services 0 25,796 K
WUDFHost.exe 1032 Services 0 8,284 K
svchost.exe 2004 Services 0 7,288 K
svchost.exe 2144 Services 0 25,432 K
svchost.exe 2184 Services 0 8,488 K
svchost.exe 2192 Services 0 19,304 K
svchost.exe 2260 Services 0 11,440 K
MsMpEng.exe 2352 Services 0 154,988 K
vmware-usbarbitrator64.ex 2444 Services 0 10,000 K
vmware-authd.exe 2496 Services 0 13,440 K
csrss.exe 3864 RDP-Tcp#6 2 12,840 K
winlogon.exe 3924 RDP-Tcp#6 2 8,400 K
dwm.exe 3988 RDP-Tcp#6 2 133,044 K
RuntimeBroker.exe 3612 RDP-Tcp#6 2 34,632 K
sihost.exe 3764 RDP-Tcp#6 2 22,676 K
explorer.exe 4024 RDP-Tcp#6 2 522,228 K
ChsIME.exe 1936 RDP-Tcp#6 2 9,064 K
ShellExperienceHost.exe 4308 RDP-Tcp#6 2 83,412 K
SearchUI.exe 4392 RDP-Tcp#6 2 47,184 K
ServerManager.exe 4700 RDP-Tcp#6 2 99,764 K
vmware-tray.exe 4936 RDP-Tcp#6 2 12,512 K
msdtc.exe 4792 Services 0 9,692 K
notepad.exe 1184 RDP-Tcp#6 2 14,124 K
dllhost.exe 3264 RDP-Tcp#6 2 9,140 K
mmc.exe 800 RDP-Tcp#6 2 17,524 K
taskhostw.exe 4352 RDP-Tcp#6 2 19,148 K
notepad.exe 724 RDP-Tcp#6 2 14,080 K
java.exe 3428 RDP-Tcp#6 2 372,520 K
java.exe 8044 RDP-Tcp#6 2 561,224 K
wordpad.exe 5724 RDP-Tcp#6 2 33,536 K
git-bash.exe 4932 RDP-Tcp#6 2 5,164 K
mintty.exe 5348 RDP-Tcp#6 2 19,216 K
bash.exe 9108 RDP-Tcp#6 2 9,644 K
git-bash.exe 5148 RDP-Tcp#6 2 5,104 K
mintty.exe 9084 RDP-Tcp#6 2 18,784 K
conhost.exe 8488 RDP-Tcp#6 2 11,724 K
bash.exe 4408 RDP-Tcp#6 2 9,588 K
git-bash.exe 756 RDP-Tcp#6 2 5,124 K
mintty.exe 2284 RDP-Tcp#6 2 18,220 K
notepad.exe 8272 RDP-Tcp#6 2 14,852 K
notepad.exe 3464 RDP-Tcp#6 2 14,436 K
conhost.exe 8756 RDP-Tcp#6 2 14,972 K
notepad.exe 9036 RDP-Tcp#6 2 15,964 K
mmc.exe 7244 RDP-Tcp#6 2 13,036 K
ApplicationFrameHost.exe 5996 RDP-Tcp#6 2 24,204 K
SystemSettings.exe 6804 RDP-Tcp#6 2 57,788 K
MpCmdRun.exe 5948 Services 0 8,160 K
tasklist.exe 4476 RDP-Tcp#6 2 8,092 K
從第2列找到進程號為4的,發(fā)現(xiàn)是System。
也可以在任務(wù)管理器查看進程對應(yīng)的服務(wù),發(fā)現(xiàn)pid=4的進程,其對應(yīng)的進程描述是NT kernel & system。
三. 遇到了“80端口被System占用”,該如何解決呢?
這是什么進程?
系統(tǒng)的80端口是被W3SVC(萬維網(wǎng)發(fā)布服務(wù),World Wide Web Publishing Service)占用了,它是系統(tǒng)提供http服務(wù)的依賴項。哪些服務(wù)使用了這個端口呢?
- World Wide Web:發(fā)布服務(wù)
- SSDP Discovery:局域網(wǎng)共享所需服務(wù)
- Print Spooler:打印機交互服務(wù)
怎么處理呢?
如果允許,可以直接不使用這個服務(wù),這個進程顯式停止是無法停止的,只有在cmd.exe里使用net stop http來停止。
(1) 關(guān)閉服務(wù)
C:\Users\Administrator>net stop http
下面的服務(wù)依賴于 HTTP Service 服務(wù)。
停止 HTTP Service 服務(wù)也會停止這些服務(wù)。
World Wide Web 發(fā)布服務(wù)
SSDP Discovery
Print Spooler
你想繼續(xù)此操作嗎? (Y/N) [N]: y
World Wide Web 發(fā)布服務(wù) 服務(wù)正在停止.
World Wide Web 發(fā)布服務(wù) 服務(wù)已成功停止。
SSDP Discovery 服務(wù)正在停止.
SSDP Discovery 服務(wù)已成功停止。
Print Spooler 服務(wù)正在停止.
Print Spooler 服務(wù)已成功停止。
HTTP Service 服務(wù)已成功停止。
或顯示如下:
(2) 禁用服務(wù)
C:\Users\Administrator>sc config http start= disabled
[SC] ChangeServiceConfig 成功
此時查看可能發(fā)現(xiàn)80端口尚未釋放,此時需重啟服務(wù)器。
重啟后,80單口端口就釋放了。
補充知識:
重新啟動http服務(wù),執(zhí)行如下命令:
C:\Users\Administrator>sc config http start= demand
C:\Users\Administrator>net start http
參考文章:
Win10 | 查找占用特定端口的進程
遇到了“80端口被占用”的問題,該如何解決?文章來源:http://www.zghlxwxcb.cn/news/detail-736900.html
NT Kernel & System 占用80端口文章來源地址http://www.zghlxwxcb.cn/news/detail-736900.html
到了這里,關(guān)于Windows 查看端口占用情況 & 80端口被占用處理方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!