【转】[Java][Idea] 打开时报错 Internal error. Address already in use: bind
方法一:
netsh winsock reset
以管理员身份运行 cmd 执行这个命令,然后重启电脑。
方法二:
按报错提示,访问 https://jb.gg/ide/critical-startup-errors
按文章,可以参考 https://youtrack.jetbrains.com/issue/IDEA-238995 解决问题
以下是文章摘抄:
Revise IDE directory locking mechanism (don't fail startup if all ports in range are taken, limited network due to firewall/VPN)
PROBLEM 1
If all the 50 ports between 6942 and 6991 are reserved, taken by the other apps or firewall doesn't allow IDE to bind on them, startup fails with the below exception:
WORKAROUND: run the following commands in the Administrator console (cmd.exe):
netsh int ipv4 set dynamicport tcp start=49152 num=16383
netsh int ipv4 set dynamicport udp start=49152 num=16383
If the above doesn't help, please try these commands instead:
net stop winnat
net start winnat
For macOS users with "Can't assign requested address" error:
See https://apple.stackexchange.com/questions/332407/how-to-change-ifconfig-lo0, this command should help:
sudo ifconfig lo0 alias 127.0.0.1
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.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.6+8-b765.25 amd64 by JetBrains s.r.o C:\Users\yatwi\AppData\Local\JetBrains\Toolbox\apps\Rider\ch-0\201.6668.197\jbr
PROBLEM 2
Unable to start the IDE with a network limited due to firewall/VPN: See IJPL-1600 for example.
WORKAROUND
Add -Djava.net.preferIPv4Stack=true
to the IDE's .vmoptions
file and start the IDE.
Check here to find the .vmoptions
file: https://intellij-support.jetbrains.com/hc/en-us/articles/206544869 .
java.util.concurrent.CompletionException: java.lang.IllegalStateException: failed to create a child event loop 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.lang.IllegalStateException: failed to create a child event loop at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:88) at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:58) at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:47) at io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:59) at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:86) at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:81) at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:68) at org.jetbrains.io.BuiltInServerKt.multiThreadEventLoopGroup(BuiltInServer.kt:144) at org.jetbrains.io.BuiltInServerKt.access$multiThreadEventLoopGroup(BuiltInServer.kt:1) at org.jetbrains.io.BuiltInServer$Companion.start(BuiltInServer.kt:54) at org.jetbrains.io.BuiltInServer.start(BuiltInServer.kt) at com.intellij.idea.SocketLock.lambda$lockAndTryActivate$2(SocketLock.java:171) at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) ... 7 more Caused by: io.netty.channel.ChannelException: failed to open a new selector at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:175) at io.netty.channel.nio.NioEventLoop.<init>(NioEventLoop.java:142) at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:146) at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:37) at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:84) ... 19 more Caused by: java.io.IOException: Unable to establish loopback connection at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:94) at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:61) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/sun.nio.ch.PipeImpl.<init>(PipeImpl.java:171) at java.base/sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50) at java.base/java.nio.channels.Pipe.open(Pipe.java:155) at java.base/sun.nio.ch.WindowsSelectorImpl.<init>(WindowsSelectorImpl.java:142) at java.base/sun.nio.ch.WindowsSelectorProvider.openSelector(WindowsSelectorProvider.java:44) at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:173) ... 23 more Caused by: java.net.ConnectException: Connection timed out: connect at java.base/sun.nio.ch.Net.connect0(Native Method) at java.base/sun.nio.ch.Net.connect(Net.java:476) at java.base/sun.nio.ch.Net.connect(Net.java:468) at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:694) at java.base/java.nio.channels.SocketChannel.open(SocketChannel.java:194) at java.base/sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(PipeImpl.java:127) at java.base/sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.java:76) ... 31 more ----- JRE 11.0.8+10-b1129.2 amd64 by JetBrains s.r.o. C:\Program Files\JetBrains\IntelliJ IDEA 203.5251.39\jbr
Or caused by Caused by: java.net.SocketException: Permission denied: connect
in last part.