4

解决windows系统某端口被占用的方法

 2 years ago
source link: https://xushanxiang.com/2022/03/windows-netstat-tasklist.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

解决windows系统某端口被占用的方法

作者: xusx 分类: 其它 发布时间: 2022-03-29 16:36

在 VSCode 中调试 koa2 程序,直接点运行后,报错。然后恢复代码为上次能正确运行的状态,再次点击运行,却提示 3000 端口已被使用。

即使关闭再打开 VSCode ,运行 koa2 程序 ,错误依旧。

解决方法步骤

  • 按住键盘上的 Windows + R 组合键,快速打开 运行 对话框。
  • 运行 对话框的输入框中输入 cmd 并回车或者点击【确定】按钮。
  • 打开 命令提示符 对话框,输入命令 netstat -ano | findstr "3000" 并回车,查看该端口对应的 PID。结果如下:
C:\Users\Administrator>netstat -ano | findstr "3000"
  TCP    0.0.0.0:3000           0.0.0.0:0              LISTENING       18660
  TCP    [::]:3000              [::]:0                 LISTENING       18660
  TCP    [::1]:3000             [::1]:8556             ESTABLISHED     18660
  TCP    [::1]:8556             [::1]:3000             ESTABLISHED     3128
  • 接着输入命令 tasklist|findstr "18660" ,然后回车,查看是哪个进程或者程序占用了 3000 端口 。结果如下:
C:\Users\Administrator>tasklist|findstr "18660"
node.exe                     18660 Console                    1     32,684 K

是 node.exe 这个应用程序占用了 。然后,打开任务管理器,找到 node.exe 进程,右键点击 结束任务 即可。

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK