端口8000,PID 4,无法终止,taskill/f/PID 4,访问被拒绝



我无法终止绑定到8000端口的进程,因此无法启动HTTP服务器。这是关于问题启动HTTP/HTTPS服务器,python-m SimpleHTTPServer

C:>taskkill /f /pid 4
ERROR: The process with PID 4 could not be terminated.
Reason: Access is denied.

即使是在下面杀人也不起作用,这是我在某个地方发现的。

C:>taskkill /f /s localhost /pid 4
ERROR: The process with PID 4 could not be terminated.
Reason: Access Denied.

PID 4是系统进程,可能在那里运行的是什么,我该如何停止它,为什么其他端口都是类似的监听方式。

C:>netstat -ab
Active Connections
  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            garg10may-PC:0         LISTENING
  RpcSs
 [svchost.exe]
  TCP    0.0.0.0:443            garg10may-PC:0         LISTENING
 [vmware-hostd.exe]
  TCP    0.0.0.0:445            garg10may-PC:0         LISTENING
 Can not obtain ownership information
  TCP    0.0.0.0:902            garg10may-PC:0         LISTENING
 [vmware-authd.exe]
  TCP    0.0.0.0:912            garg10may-PC:0         LISTENING
 [vmware-authd.exe]
  TCP    0.0.0.0:8000           garg10may-PC:0         LISTENING
 Can not obtain ownership information

如果您在Windows中,这可能会对您有所帮助,端口80通常被此服务使用:"万维网发布服务",打开控制面板中的"服务"并停止

根据python文档,也可以使用带有端口号参数的解释器的-m开关直接调用http.server模块。与前面的示例类似,它为相对于当前目录的文件提供服务。

python -m http.server 8000

如果您的端口8000已经在使用,只需将其更改为另一个编号。

python -m http.server 5000

武断地杀死进程和更多的系统进程不是一个好主意。

不要这样做-你不能杀死它是有原因的,因为你没有启动它。而是传递另一个端口号:

对于Python 3:

python -m http.server 8080

对于Python 2:

python -m SimpleHTTPServer 8080

最新更新