Tomcat启动报错:java.net.BindException: Cannot assign requested address: JVM_Bind

Tomcat启动异常解析
本文详细解析了Tomcat启动时报错java.net.BindException的具体原因,通过排除端口冲突及检查hosts文件,最终定位到错误是由于hosts文件中存在无效的本地IP地址导致。移除该无效条目后,Tomcat成功启动。

  Tomcat启动报错:java.net.BindException: Cannot assign requested address: JVM_Bind

  Tomcat Cannot assign requested address: JVM_Bind 非端口占用冲突

严重: StandardServer.await: create[8005]: 
java.net.BindException: Cannot assign requested address: JVM_Bind
    at java.net.PlainSocketImpl.socketBind(Native Method)
    at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:359)
    at java.net.ServerSocket.bind(ServerSocket.java:319)
    at java.net.ServerSocket.(ServerSocket.java:185)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:406)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:676)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:628)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

  可能是Tomcat需要绑定的端口或某些资源其他应用程序占用

  使用DOS命令netstat -an查看被占用的端口,并未发现有任何程序占用Tomcat使用的相关端口(例如8080),并且将Tomcat安装目录下的conf/server.xml文件中的端口改为其他端口,再次运行也无法正常启动。

  通过多种测试,可以初步判断应该不是端口占用引起的问题。如果不是端口占用的问题的话,那么就要考虑是否是IP绑定的问题了。

  经过检查,在服务器计算机的C:\Windows\System32\drivers\etc\hosts文件中发现如下部分内容:

127.0.0.1       localhost
169.196.254.14    localhost

  169.196.254.14是一个不存在的本地IP地址,将hosts文件中的第二行内容169.196.254.14 localhost去掉后,再次启动Tomcat,发现运行正常!

  在服务器领域,一台计算机配置多个IP地址是比较常见的。Tomcat在启动时,会根据配置去获取所有的IP地址,并且进行逐个绑定,当发现需要绑定的IP地址不存在时,将会触发上述异常,从而导致无法正常启动。

//输出localhost映射的所有IP地址
InetAddress[] ips = InetAddress.getAllByName("localhost");
if (ips != null) {
    for (InetAddress ip : ips) {
        System.out.println(ip.getHostAddress());
    }
}
/* 修改上述hosts文件前,输出:
* 169.196.254.14
* 127.0.0.1
* 修改文件后,输出
* 127.0.0.1
*/

 

转载于:https://www.cnblogs.com/lojun/p/7652835.html

2025-08-26 17:34:36.210 ERROR 27004 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.context.ApplicationContextException: Failed to start bean 'shadedNettyGrpcServerLifecycle'; nested exception is java.lang.IllegalStateException: Failed to start the grpc server at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:357) ~[spring-context-5.3.31.jar:5.3.31] at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_362-362] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:156) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:124) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:946) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:594) ~[spring-context-5.3.31.jar:5.3.31] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.7.18.jar:2.7.18] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) [spring-boot-2.7.18.jar:2.7.18] at com.tplink.nbu.demo.basicspringboot.BasicSpringBootApplication.main(BasicSpringBootApplication.java:13) [classes/:na] Caused by: java.lang.IllegalStateException: Failed to start the grpc server at net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle.start(GrpcServerLifecycle.java:74) ~[grpc-server-spring-boot-autoconfigure-2.14.0.RELEASE.jar:2.14.0.RELEASE] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:179) ~[spring-context-5.3.31.jar:5.3.31] ... 14 common frames omitted Caused by: java.io.IOException: Failed to bind to address /127.0.0.0:8091 at io.grpc.netty.shaded.io.grpc.netty.NettyServer.start(NettyServer.java:328) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.internal.ServerImpl.start(ServerImpl.java:184) ~[grpc-core-1.51.0.jar:1.51.0] at io.grpc.internal.ServerImpl.start(ServerImpl.java:93) ~[grpc-core-1.51.0.jar:1.51.0] at net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle.createAndStartGrpcServer(GrpcServerLifecycle.java:113) ~[grpc-server-spring-boot-autoconfigure-2.14.0.RELEASE.jar:2.14.0.RELEASE] at net.devh.boot.grpc.server.serverfactory.GrpcServerLifecycle.start(GrpcServerLifecycle.java:72) ~[grpc-server-spring-boot-autoconfigure-2.14.0.RELEASE.jar:2.14.0.RELEASE] ... 15 common frames omitted Caused by: java.net.BindException: Cannot assign requested address: bind at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_362-362] at sun.nio.ch.Net.bind(Net.java:461) ~[na:1.8.0_362-362] at sun.nio.ch.Net.bind(Net.java:453) ~[na:1.8.0_362-362] at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222) ~[na:1.8.0_362-362] at io.grpc.netty.shaded.io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[grpc-netty-shaded-1.56.1.jar:1.56.1] at java.lang.Thread.run(Thread.java:750) ~[na:1.8.0_362-362]
最新发布
08-27
问题: doPost error: java.net.BindException: Cannot assign requested address 回答: 这个错误通常发生在服务器端进行new ServerSocket(port)或者socket.bind(SocketAddress bindpoint)操作时,表示无法分配请求的地址。\[1\]这个错误可能是由于服务器上的端口已经被其他进程占用导致的。另外,在Tomcat日志中也可能会出现类似的错误信息,如"java.io.IOException: Too many open files"。\[3\]这个错误通常是由于打开的文件数目过多导致的。要解决这个问题,可以尝试关闭一些不必要的文件或者进程,以释放资源。 #### 引用[.reference_title] - *1* *2* [----------ORG.APACHE.CATALINA.CONNECTOR.CLIENTABORTEXCEPTION: JAVA.IO.IOEXCEPTION: BROKEN PIPE](https://blog.csdn.net/liu_dong_kang/article/details/109705994)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [----------org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe...](https://blog.csdn.net/weixin_33881140/article/details/93280213)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值