zoukankan      html  css  js  c++  java
  • tomcat服务器输入localhost可以访问,ip无法访问解决办法

    最近在开发项目中,遇到的一个问题是:

    在 tomcat中发布一个web项目,但是发布成功后,只能用http://localhost:8080/fm访问项目,不能用

    http://127.0.0.1:8080/fm访问项目,也不能用本地的IP地址访问(http://192.16/8.0.191:8080/fm

    起初认为是防火墙的原因,但是防火墙是关闭的,应该没有影响;

    后来认为是win7的原因,那个远程那有个不允许远程访问,但是更改了都没有效果;

    再后来认为是想原来tomcat6的时候,没有出现过此问题,所以现在觉得应该是tomcat5的问题。

    经过从网上查找,原因应该是tomcat绑定IP地址的问题,可以通过ping localhost查看IP是哪种格式,现解决方案如下:

    (借鉴而得的解决方法)

    1. 使用cmd命令netstat -n, 查看tomcat地址绑定, 发现是绑定到::1, IPv6.

    2. 配置tomcat的server.xml, 更改connector配置, 端口不用改, 加上address="0.0.0.0", 使其绑定到IPv4, 如下

    (借鉴的解决方案)
    <1>使用cmd命令netstat -n, 查看tomcat地址绑定, 发现是绑定到::1, IPv6;
    <2>配置tomcat的server.xml, 更改connector配置, 端口不用改, 加上address="0.0.0.0", 使其绑定到IPv4
    <Connector port="8080" maxHttpHeaderSize="8192" address="0.0.0.0"
                   maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
                   enableLookups="false" redirectPort="8443" acceptCount="100"
                   connectionTimeout="20000" disableUploadTimeout="true" />
    <3>重启tomcat, 再次使用netstat -n, 查看tomcat地址绑定, 已变为IPv4.
    此问题即可迎刃而解。
  • 相关阅读:
    unable to retrieve container logs for docker kubernetes
    Restart container within pod
    Kubernetes1.3:POD生命周期管理
    Options of the DB storage of prometheus
    prometheus重启hang住问题记录
    prometheus交流资源
    nc 从服务器上传下载文件
    负载均衡监控需求
    prometheus消耗内存问题
    10.Docker 镜像使用
  • 原文地址:https://www.cnblogs.com/smuxiaolei/p/7490248.html
Copyright © 2011-2022 走看看