When Tomcat publishes a project, localhost can access it with an IP address that is inaccessible to other computers.

Source: Internet
Author: User

One of the problems recently encountered in the development project was the publication of a Web project in Tomcat, but after the publication was successful, only Http://localhost:8080/aml access to the project was possible, and the project could not be accessed with Http://172.0.0.1:8080/aml. Nor can it be accessed with a local IP address, while other colleagues ' computers are inaccessible.

It was initially thought to be a firewall problem, but after shutting down the firewall, it was still inaccessible. At the same time, it is not allowed to turn off remote access. Later, when viewing the information, I know that Tomcat bound IP address problem, and Win7 by default is the IPv6 protocol, ping localhost to see what the IP format, learned: 1 IPv6.

First Solution:

1: Start tomcat, use the cmd command: D:\tomcat\bin>netstat-an | findstr "8080" to view the Tomcat address bindings.

2: Configure Tomcat's server.xml, change the connector configuration, the port does not change, add address= "0.0.0.0", bind it to IPv4. The configuration is as follows:

1 <  port= "8080" address= "0.0.0.0"  protocol= "http/1.1"2                ConnectionTimeout = "20000" 3                redirectport= "8443"/>

3: Restart Tomcat to view the Tomcat address bindings again. found that the binding address has become the 0.0.0.0:8080,IPV4 protocol.

In addition, the Address property's modification allows Tomcat to bind the specified IP, such as: address= "127.0.0.1", so Tomcat listens only to port 8080 of the IP address 127.0.0.1. (By default, it listens for all IPs.) )

  

When Tomcat publishes a project, localhost can access it with an IP address that is inaccessible to other computers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.