Tomcat t修改server.xml的端口为80后启动,无法正常访问tomcaCould not contact localhost:8005. Tomcat may not be running

tomcat修改server.xml的端口为80后启动,无法正常访问tomcat页面的页面,修改回来用8080端口依旧无法正常打开,关闭tomcat后报Catalina.stop: java.net.ConnectException: 拒绝连接 (Connection refused)的错误,首先查看是否80端口被占用了。

tomcat关闭时报Catalina.stop: java.net.ConnectException: 拒绝连接 (Connection refused)的错误

在Linux中的启动Tomcat的时候无异常,但是通过脚本文件关闭Tomcat的时候,出现异常
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Jul 20, 2018 3:17:45 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSoc
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.j
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at java.net.Socket.(Socket.java:434)
at java.net.Socket.(Socket.java:211)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:498)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

解决方法:
重将server.xml中的端口改为8080
然后:iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
(如果用到443,也相应执行以上方法)
即可!

你可能感兴趣的:(mysql,java,tomcat,mysql)