Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running.

SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running.

错误信息

[root@iZ8vb89vghpyeru53i4xflZ bin]# ./shutdown.sh 
Using CATALINA_BASE:   /home/mytomcat/apache-tomcat-9.0.65
Using CATALINA_HOME:   /home/mytomcat/apache-tomcat-9.0.65
Using CATALINA_TMPDIR: /home/mytomcat/apache-tomcat-9.0.65/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /home/mytomcat/apache-tomcat-9.0.65/bin/bootstrap.jar:/home/mytomcat/apache-tomcat-9.0.65/bin/tomcat-juli.jar
Using CATALINA_OPTS:   
Aug 12, 2022 3:35:33 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running.
Aug 12, 2022 3:35:33 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Error stopping Catalina
java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	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.<init>(Socket.java:434)
	at java.net.Socket.<init>(Socket.java:211)
	at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:667)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:391)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:481)

以上错误信息:我使用Xshell终端连接阿里云服务器时,通过Linux命令解压安装tomcat出现的错误,我通过startup.shshutdown.sh 测试tomcat是否安装成功,但是当我输入./shutdown.sh 关闭tomcat却出现以上错误;

分析出错原因

从字面翻译来看:”不能与8005端口建立联系,推断tomcat没有运行“,但实际上tomcat我已经成功运行并且没有保错,关闭tomcat却出现了错误。

我们都知道启动访问测试Tomcat默认端口号是8080,那么为什么会出现8005端口呢?

因此我想要解决这个错误就要从这个8005端口入手。通过查阅资料发现8005端口是关闭Tomcat服务所需要的端口。

通过上述了解就可以大致推断出,报错的含义,也就是说8005端口没有打开,按理说在Tomcat正常运行期间8005端口也应该和8080端口一样被打开,因为8005端口未打开,然后Tomcat就推断“Tomcat没有启动”,那为什么windows系统测试tomcat没有出现这种情况呢?

查阅资料,有人说Linux系统启动tomcat端口启动较慢

因此我测试启动Tomcat多次,虽然tomcat启动成功后,查询8080端口也已经启动,但是通过云服务器公网ip登录tomcat页面需要等一分钟左右页面才会加载出来

Could not contact [localhost:8005] (base port [8005] and offset [0]). Tomcat may not be running._第1张图片

  • 通过图片也可以看到:tomcat刚刚启动后我查询了三次已经开启的端口号,知道查询第三次8005端口才被开启
  • 总结:8005用于关闭tomcat服务的端口确实开启的比8080端口慢,并且即使8080端口在tomcat运行后立刻被开启,测试访问tomcat页面也不能被立刻加载!

你可能感兴趣的:(Linux,tomcat,java,开发语言)