首页 > 编程语言 >【转】[Java][Idea] 打开时报错 Internal error. Address already in use: bind

【转】[Java][Idea] 打开时报错 Internal error. Address already in use: bind

时间:2024-11-12 17:58:00浏览次数:1  
标签:netty use already java nio util base io Java

方法一:

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.

标签:netty,use,already,java,nio,util,base,io,Java
From: https://www.cnblogs.com/z5337/p/18542370

相关文章

  • 【Java Web】EL表达式
    文章目录EL表达式EL功能获取对象属性获取集合元素数据处理运算屏蔽常见异常自动类型转换EL访问作用域举例一个简单的用户信息展示场景,包含用户的姓名和年龄。下面分别用JSP脚本和EL表达式两种方式实现这个功能。使用JSP脚本<%@pagecontentType="text/h......
  • 【Java】Java读写Excel文件
    常见的JavaExcel操作方法Java中常用的Excel操作方式有什么呢?ApachePOIEasyExcel这两种方法有什么区别和联系?ApachePOI是一个用于操作MicrosoftOffice格式文件(如Excel、Word等)的Java库。它提供了一系列的API来读写Excel文件。POI的基本功能如下:结构说......
  • 【MonitorUtil】java报错日志工具类
     自定义报警日志打印工具importorg.apache.commons.lang.StringUtils;importjava.io.PrintWriter;importjava.io.StringWriter;/***自定义报警日志打印工具**@authorAngel挤一挤*@date2022/12/13*/publicclassMonitorUtil{/***......
  • 《Java核心技术 卷I》图形用户界面使用字体
    使用字体字体名(fontfacename)指定一种字体,字体名由字体族名(fontfamilyname)和一个可选的后缀(如果"Bold")组成,例如,“Helvetica”和"HelveticaBold"都属于名为“Helvetica”字体族的字体。要想知道某台特定计算机上可用的字体,可以调用GraphicsEnvironment类的getAvaila......
  • 深入 Java 多线程:解锁并发编程的奥秘
    在当今的软件开发世界中,性能和高并发是衡量一个应用程序成败的关键因素。无论是处理高流量的网络请求、执行复杂的数据分析任务,还是管理后台服务中的资源,Java多线程编程都是开发者必备的技能之一。本文将带领你深入Java多线程的世界,解锁并发编程的奥秘。1.并发与并行的区......
  • 2024年Java 八股文-基础篇
    1.为什么说Java语言“编译与解释并存”?高级编程语言按照程序的执行方式分为编译型和解释型两种。简单来说,编译型语言是指编译器针对特定的操作系统将源代码一次性翻译成可被该平台执行的机器码;解释型语言是指解释器对源程序逐行解释成特定平台的机器码并立即执行。比如,你......
  • Java中2个Integer比较相同的4种方式
    Java中2个Integer比较相同的4种方式概要使用前切记Integer的范围是【-128~127】例如:Integera=128;Integerb=128;1,使用==比较【-128~127】区间内返回true,否则返回false//==比较if(a==b){System.out.println("a,b使用==比较返回结果:true");......
  • 20天精通Java,day1
    面向对象编程static(静态):修饰成员变量和成员方法。类变量和类方法:有static修饰,属于类,在计算机中只有一份,会被类的全部对象共享。既可以通过类名访问(推荐),也可以通过对象名访问。类变量应用场景:在开发中如果某个数据只需要一份,且希望能够被共享(访问,修改),则该数据可以被定义成类......
  • 【JAVA】Java基础—面向对象编程:构造方法-实现一个Car类,包含多个构造方法,创建不同的汽
    在Java中,构造方法则是用于创建对象的特殊方法。通过构造方法,可以在创建对象时初始化其属性。构造方法的重载允许我们根据不同的需求定义多个构造方法,从而灵活地创建对象。我们可以将汽车的构造方法比作汽车的配置选项。比如,当你购买一辆汽车时,你可以选择不同的配置,如颜色、型......
  • 新手入门Java自动化测试的利器:Selenium WebDriver
    新手入门Java自动化测试的利器:SeleniumWebDriver今天我们将深入探讨一款强大的Java自动化测试工具——SeleniumWebDriver。在正式介绍SeleniumWebDriver之前,让我们首先对Selenium本身进行简要概述,以便更好地理解其背景和功能。官方学习网站:https://www.selenium.dev/Sele......