idea 启动时,报错 Start Failed

  • 问题分析
  • 解决方法
    • 修改动态端口范围
    • 将idea所需端口设置为排除端口
  • 参考连接

报错信息

Internal error. Please refer to http://jb.gg/ide/critical-startup-errors

java.util.concurrent.CompletionException: java.net.BindException: Address already in use: bind
    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1702)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.BindException: Address already in use: bind
    at java.base/sun.nio.ch.Net.bind0(Native Method)
    at java.base/sun.nio.ch.Net.bind(Net.java:455)
    at java.base/sun.nio.ch.Net.bind(Net.java:447)
    at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
    at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134)
    at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:550)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506)
    at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491)
    at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
    at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:248)
    at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    ... 1 more

-----
JRE 11.0.8+10-b944.34 amd64 by JetBrains s.r.o.
C:\Program Files\JetBrains\IntelliJ IDEA 2020.2.3\jbr

问题分析

idea启动时需要绑定6942~6991内的第一个可用的端口,如果这些端口被其他程序或者防火墙保留(或占用),则idea会启动失败,注意出错信息第二行里的Address already in use

我是由于安装了Windows下的Docker Desktop,开启了Hyper-V。开启Hyper-V后,系统会从默认的tcp动态端口范围内分配一些保留端口供Hyper-V使用。可以在cmd中:

  • 使用命令netsh interface ipv4 show excludedportrange protocol=tcp 查看端口排除范围。
  • 使用命令netsh int ipv4 show dynamicport tcp查看系统默认的tcp动态端口范围。(一般是 1024~15000

解决方法

修改动态端口范围

首先要使用管理员身份运行cmd,然后使用命令修改动态端口范围

  • netsh int ipv4 set dynamicport tcp start=49152 num=16383

  • netsh int ipv4 set dynamicport udp start=49152 num=16383

以上命令使用后,idea可能还是不能打开,是因为服务还没有重启。再使用以下命令即可

  • net stop winnat
  • net start winnat

将idea所需端口设置为排除端口

同样使用管理员身份打开cmd,然后将6942~6991设置为排除端口给应用程序使用

  • 使用命令netsh int ipv4 add excludedportrange protocol=tcp startport=6942 numberofports=10 保留 6942~6951 这10个端口给应用程序使用

若要查看被保留的端口,使用命令

  • netsh int ipv4 show excludedport tcp
  • 带*的是被管理员保留的端口,可以被应用程序使用。

如果要取消保留端口,可以使用命令

  • Copynetsh int ipv4 delete excludedportrange protocol=tcp startport=9090 numberofports=1

参考连接

  • Win10 各种端口占用问题的解决办法
  • Revise IDE folders locking mechanism (don’t fail startup if all ports in range are taken)
  • Start Failed, Internal error: recovering IDE to the working state after the critical startup error
  • Hyper-V和IDEA运行端口占用问题
  • 修改Hyper-V动态端口范围
  • Critical Internal Error on Startup of IntelliJ IDEA: “Cannot Lock System Folders”

你可能感兴趣的:(错误解决,java,intellij,idea,hyper-v,ports,cmd)