google was no help I figured I should document this somewhere.
Tomcat startup gave the notorious java.net.BindException: Cannot assign requested address. This usually means that another process is listening on the same port on this machine. I started with ps -ef grep java to make sure that no other tomcat process was running on the machine. Nothing.
I suspected that maybe some other web server was holding the port, but netstat -an showed that nothing binds this address. Moreover, telnet localhost 80 showed that no one is listening.
Looking at the server.xml I found out that the connector was binding to the hostname "demoserver" on port 80.
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"address="demoserver" port="80" minProcessors="5" maxProcessors="75"enableLookups="true" redirectPort="8443"acceptCount="100" debug="0" connectionTimeout="20000"useURIValidationHack="false" disableUploadTimeout="true" />
trying to ping demoserver gave me errors, but nslookup demoserver gave me the right ip address.
After a few minutes I noticed that some clown added demoserver to /etc/hosts with the wrong ip address. Fixing /etc/hosts to have the right ip address for demoserver made tomcat work
分享到:
相关推荐
在应用程序中调用不同服务时,经常会遇到No route to host程序异常的问题。下文分享该问题的排查过程与解决方法。
项目中碰到的,记录一下解决方案
格式化namenode时 报错 No Route to Host from node1/192.168.3.101 to hadoop05:8485 failed on socket timeout exception: java.net.NoRouteToHostException: No route to host解决方案 一、报错信息概要: 在配置...
java.net.NoRouteToHostException: No route to host 是 Hadoop 中的常见问题,主要是由于网络连接问题。解决方法是停止 iptables 服务,例如使用 `sudo /etc/init.d/iptables stop` 命令。 更改 namenode 后,在 ...
- **错误现象1:java.net.NoRouteToHostException: No route to host** - 原因:此错误通常由于防火墙阻止了通信导致。 - 解决方法:关闭Master服务器上的防火墙,例如在Linux环境下使用`chkconfig iptables off`...
启用DNSSEC需要配置`java.net.useSystemProxies`和`java.net.preferIPv4Stack`系统属性。 4. **自定义DNS解析**: - 对于复杂的应用场景,Java允许通过实现`java.net.DnsResolver`接口创建自定义的DNS解析逻辑。这...
在Java中,网络编程涉及到几个关键的类,它们位于`java.net`包下。对于IP层,`InetAddress`类用于标识网络上的硬件资源,可以通过IP地址或主机名创建。对于应用层,`URL`类是统一资源定位符,它能够定位互联网上的...
Java提供了一套强大的API,位于`java.net`包及其子包中,用于处理网络通信的各种需求。本章节将深入探讨Java网络编程的基础知识,包括TCP和UDP协议、IP地址、端口号以及套接字的概念。 首先,Java中的网络API支持IP...
如`ConnectException`表示连接失败,`SocketException`通常与网络连接有关,`MalformedURLException`则是在解析URL时格式错误,`UnknownHostException`是无法解析主机名,`NoRouteToHostException`表示无法找到到...