端口8000,PID 4,无法杀死,taskill /f /pid 4,拒绝访问

2024-06-16 10:36:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法终止绑定到8000端口的进程,因此无法启动HTTP服务器。这是关于问题的 Start HTTP/HTTPS server, 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

Tags: the端口http进程noterrorpidexe
3条回答

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

对于Python 3:

python -m http.server 8080

对于Python 2:

python -m SimpleHTTPServer 8080

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

根据pythondocumentation,还可以使用带有端口号参数的解释器的-m开关直接调用http.server模块。与前一个示例类似,它提供与当前目录相关的文件。

python -m http.server 8000

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

python -m http.server 5000

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

相关问题 更多 >