经验分享:对于刚接触开发的大学生,怎么在Windows查看与关闭端口占用方法?

123 阅读1分钟
![](https://upload-images.jianshu.io/upload_images/24762785-494e5690468d2571.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

前言:做开发有的时候会发现某一端口被占用了而导致不能正常启动服务,这个时候就需要把这个端口释放掉了,步骤如下

观察报错信息提示,了解是哪个端口号被占用,以8700为例

按win+r输入cmd打开控制台,输入netstat -aon|findstr "8700".可以看到是进程号为10744的程序占用了该端口号

![](https://upload-images.jianshu.io/upload_images/24762785-4bbff177b9a3b9a4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

关闭该进程,指令为taskkill -PID 进程号 -F

![](https://upload-images.jianshu.io/upload_images/24762785-fd3422e1c17da3fe.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

补充另一种关闭方式,先用指令tasklist|findstr "8700"可以看到是占用端口的进程名,然后用指令taskkill /f /t /im 进程名来关闭该进程。这个方法麻烦些,不过能更清楚是那个程序,关起来也放心些。

![](https://upload-images.jianshu.io/upload_images/24762785-d29e5ebfa78e5b7d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

点击了解更多资料,更有免费开源项目和课程等你观看哦!

![](https://upload-images.jianshu.io/upload_images/24762785-79e8b2ce1b2b0929.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)