【已解决】IEDA启动SpringBoot项目失败,提示端口被占用,但确认端口并没有被占用

内容最初来源于我在博客园发的博客,当时(21.01.30)遭遇了这个问题各种搜索尝试均无解,带着郁闷的心情写下这篇博客【未解决】IEDA启动SpringBoot项目失败,提示端口被占用,但确认端口并没有被占用 - likeqc - 博客园 (cnblogs.com)

万万没想到时隔两年后的今天,上午的时候又遭遇了这个问题,吐槽一番后阴差阳错搜到了解决方案:

记录一次端口占用问题的解决过程 | NeverKnowsTomorrow

才发现这样的问题我在之前懂得都懂时就碰到并解决过了,谁先谁后记不清了,只是没有把两件事联系起来

问题原因:win系统会有一些动态的保留端口,重启之后可能会变化(也就是说也可能不会变化,所以重启解决不了问题)

解决方法:

powershell 管理员启动 执行如下命令:

// 查看被保留的端口范围
netsh interface ipv4 show excludedportrange protocol=tcp
// 用到的端口排除在保留端口范围就可以了
netsh int ipv4 add excludedportrange protocol=tcp startport = 起始端口 numberofports = 端口保留数量 
// 报错“另一个程序正在使用此文件,进程无法访问。”时,可以尝试关闭 Hyper-V、虚拟机平台、WSL 功能,然后重启后再次尝试。
// 或者也可以换一种方式
// 重置动态端口的范围,然后重启电脑
netsh int ipv4 set dynamicport tcp start=49152 num=16383

——下面是原文,上面是更新,内类大多来自前面提到的另一篇博客——

这几天正在学习的SpringBoot项目,突然就启动不起了,报错

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 9014 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 9014, or configure this application to listen on another port.


Process finished with exit code 1

但是通过cmd命令netstat -ano | findstr "9014"

PS C:\Windows\system32> netstat -ano | findstr 9014
PS C:\Windows\system32> netstat -ano | findstr "9014"
PS C:\Windows\system32>

发现找不到占用该端口的进程,尝试了重启软件、重启电脑、更新软件,都无法解决,迷惑!!!(能找到的话直接结束进程即可 taskkill /pid 123456 /f
代码没问题,修改端口就能运行了,但是用原来的端口就是不行,哪怕没有被占用。

posted @ 2021-01-30 21:11  likeqc  阅读(2540)  评论(7)    收藏  举报