Tomcat Cannot assign requested address: JVM_Bind is not a port occupation conflict

Recently, when I started Tomcat 7.0, I found that it could not be started correctly. The main exception stack information is as follows:

严重: 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 7.0 is the official free installation and has just been downloaded, so it shouldn't be a problem with missing files.

 

According to the abnormal information, it may be that the port that Tomcat needs to bind or some resources are occupied by other applications.

 

Use the DOS command netstat -an to view the occupied ports, and no program is found to occupy the relevant ports (such as 8080) used by Tomcat, and change the port in the conf/server.xml file in the Tomcat installation directory to another port, Running it again does not start normally.

 

Through a variety of tests, it can be preliminarily judged that the problem should not be caused by port occupation. If it is not a problem of port occupation, then it is necessary to consider whether it is a problem of IP binding.

 

After inspection, the following parts were found in the C:\Windows\System32\drivers\etc\hosts file of my friend's server computer:

127.0.0.1       localhost
10.10.13.67    localhost

10.10.13.67 is a local IP address that does not exist. After removing the second line of 10.10.13.67  localhost in the hosts file , start Tomcat again and find that it is running normally!

 

In the server world, it is common for a computer to be configured with multiple IP addresses. When Tomcat starts, it will obtain all IP addresses according to the configuration, and bind them one by one. When it finds that the IP address to be bound does not exist, the above exception will be triggered, resulting in failure to start normally.

// Output all IP addresses mapped by localhost
InetAddress[] ips = InetAddress.getAllByName("localhost");
if (ips != null) {
    for (InetAddress ip : ips) {
        System.out.println(ip.getHostAddress());
    }
}
/* Before modifying the above hosts file, output:
* 10.10.13.67
* 127.0.0.1
* After modifying the file, output
* 127.0.0.1
*/

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326714083&siteId=291194637