问题定位
查看idea的log,默认的log目录:
%localappdata%\JetBrains\${IntelliJIdea+版本}\log
查看idea.log找到启动失败的描述,我碰到的问题是idea报端口被占用。
原因
idea的官网也有人问过这个问题:
idea官网问题描述
原因描述如下:
To lock the folders IDE is starting a server on localhost, it tries to bind on the first available port between 6942 and 6991, this exception is thrown if IDE was not able to bind on any of the ports in this range. All 50 ports are unlikely to be already used on a machine, so it appears to be a networking issue or some security software which doesn’t permit the IDE to bind on any port in this range even on the localhost interface.
On Windows “netsh winsock reset” in the Administrator console followed by the reboot should help. Also try disabling the antivirus/firewall and verify that the network configuration is correct.
有兴趣的浏览一下问题,其主要原因是:IDEA启动时会绑定6942-6991范围内第一个可用的端口,而这些端口被占用。一般情况下这50个端口同时被占用的可能性比较低,大概率是被软件预留了,比如Hyper-V或者docker。
此时使用指令查看一下保留端口即可:
netsh interface ipv4 show excludedportrange protocol=tcp
解决方法
没有找到idea怎么修改bind端口,那就只能修改hyper-v的保留端口了,修改方法参考docker问题描述中enashed提供的方法:
解决方法
把其中的50051端口号改成6942~6991间的任一个数字,这样就预留出idea使用的端口了。