Linux tomcat 正在运行,但是 8080 端口没有响应

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8554663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:42:50  来源:igfitidea点击:

tomcat running ,but 8080 port not responding

linuxtomcatport

提问by Ulises Layera

I have installed sun jdk 1.6 x64 and tomcat in a linux x64 machine through ssh, i don't have root privileges so i installed both in my home dir.

我已经通过 ssh 在 linux x64 机器上安装了 sun jdk 1.6 x64 和 tomcat,我没有 root 权限,所以我都安装在我的家庭目录中。

I managed to successful run tomcat but if i try to enter mydomain.com:8080 there's no answer from the server.

我设法成功运行了 tomcat,但是如果我尝试输入 mydomain.com:8080,则服务器没有响应。

With this command:

使用此命令:

netstat -atnp|grep LISTEN

i checked the port and it is LISTENING

我检查了端口,它正在侦听

Dec 18, 2011 5:11:20 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /home2/fiegmund/jdk1.6.0_25/jre/lib/amd64/server:/home2/fiegmund/jdk1.6.0_25/jre/lib/amd64:/home2/fiegmund/jdk1.6.0_25/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Dec 18, 2011 5:11:21 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 18, 2011 5:11:21 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 18, 2011 5:11:21 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2015 ms
Dec 18, 2011 5:11:21 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 18, 2011 5:11:21 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
Dec 18, 2011 5:11:21 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/docs
Dec 18, 2011 5:11:24 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [1,869] milliseconds.
Dec 18, 2011 5:11:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/manager
Dec 18, 2011 5:11:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/ROOT
Dec 18, 2011 5:11:24 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/examples
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /home2/fiegmund/apache-tomcat-7.0.23/webapps/host-manager
Dec 18, 2011 5:11:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 18, 2011 5:11:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 18, 2011 5:11:25 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4582 ms>

Any ideas of what is the problem?

任何想法是什么问题?

Thanks in advance and sorry for the terrible english I wrote.

预先感谢并为我写的糟糕的英语感到抱歉。

采纳答案by MK.

First step is to run telnet localhost 8080 when logged in locally. Then type in something like

第一步是在本地登录时运行 telnet localhost 8080 。然后输入类似的东西

GET /

and you should get HTML back. If that doesn't work, then tomcat is not really running properly or is not listening on port 8080. If that works but when trying from outside, make sure that you have the correct ip address. Try with ip address first. If ip address works, perhaps your mydomain.com doesn't resolve to it. If ip is correct (the same one you are ssh'ing to) and it still doesn' work, then you are probably running firewall which doesn't allow 8080 through. Changing firewall configuration requires root access.

你应该得到 HTML 回来。如果这不起作用,则 tomcat 没有真正正常运行或未在端口 8080 上侦听。如果可行,但从外部尝试时,请确保您拥有正确的 IP 地址。先用ip地址试试。如果 ip 地址有效,可能您的 mydomain.com 无法解析它。如果 ip 正确(与您正在使用的 ssh 相同)并且它仍然不起作用,那么您可能正在运行不允许 8080 通过的防火墙。更改防火墙配置需要 root 访问权限。

回答by Samir Kumar

Close the IDE. Restart the process java.exe if you are on a windows system. And fire up the IDE after that.

关闭 IDE。如果您使用的是 Windows 系统,请重新启动进程 java.exe。然后启动IDE。

回答by Chaminda Bandara

Try to list out using following command on Linux terminal LISTEN TCP Addresses and port details with program name

尝试在 Linux 终端上使用以下命令列出 LISTEN TCP 地址和端口详细信息以及程序名称

netstat -ltnpa | grep -i --colour LISTEN

Further you have to check firewall is turn on or off. (Most of the time there might be turn on and may have blocked the specific default tomcat 8080 port blocked by iptables in linux)

此外,您必须检查防火墙是打开还是关闭。(大多数时候可能是打开的,可能是linux中iptables阻塞的特定默认tomcat 8080端口被屏蔽了)

回答by eis

The problem for me was that my Tomcat started listening to IPv6 ONLY. Putting it here in case somebody else finds out the same thing.

我的问题是我的 Tomcat 开始只监听 IPv6。把它放在这里以防其他人发现同样的事情。

I was able to get proper responses with

我能够得到适当的回应

curl -g -6 "http://[::1]:8080/"

But not with localhost. To fix this, I removedaddressattribute from conf/server.xml:

但不是本地主机。为了解决这个问题,我从 conf/server.xml 中删除了address属性:

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" URIEncoding="UTF-8" />
           address="0.0.0.0" />

and restarted and it bound to IPv4 again. I know it should be other way around, but this was what fixed it for me. OS was Ubuntu.

并重新启动,它再次绑定到 IPv4。我知道它应该是相反的,但这就是为我修复它的原因。操作系统是 Ubuntu。

回答by PANKAJ VERMA

In case of war deployment if there is error in war file, tomcat may not be able to extract the war file. Make sure a folder having same name as war file is created in tomcat//libexec/webapps otherwise localhost:8080 will stuck.

在war部署的情况下,如果war文件有错误,tomcat可能无法解压war文件。确保在 tomcat//libexec/webapps 中创建了一个与 war 文件同名的文件夹,否则 localhost:8080 会卡住。

回答by fafaro

Tomcat may be too slow to start if one of the deployed applications is too slow to initialize. You can tell this is the case when you've started Tomcat, yet the browser says the server isn't responding, even though you can see that the port is listening (by connecting with telnet). Also note that your CPU usage may be too high. In my case, it was because I had enabled TRACE mode on the logger.

如果部署的应用程序之一太慢而无法初始化,Tomcat 可能会太慢而无法启动。当您启动 Tomcat 时,您可以看出这是这种情况,但浏览器说服务器没有响应,即使您可以看到端口正在侦听(通过使用 telnet 连接)。另请注意,您的 CPU 使用率可能过高。就我而言,这是因为我在记录器上启用了 TRACE 模式。

回答by Tom Chamberlain

On CentOs I had to open the firewall manually

在 CentOs 上我必须手动打开防火墙

sudo firewall-cmd --zone=public --add-port=7999/tcp --permanent
sudo firewall-cmd --reload

Not sure how, but if Docker was running a container on the same port, it would automatically open the firewall and so was throwing me off

不知道如何,但如果 Docker 在同一个端口上运行一个容器,它会自动打开防火墙,所以让我失望

回答by simon otwero

You can try confirm the status of the server by running:

您可以尝试通过运行来确认服务器的状态:

 lsof -i :8080