I have Tomcat7 installed on an AWS EC2 machine running Ubuntu 16.04. I start Tomcat7 on port 8080, and, from that same machine, can telnet to localhost 8080, execute "GET /", and see the index page.

However, when I telnet to it from a different machine, a connection is made, I can execute "GET /", but then the connection closes with no response. I know that it is connecting to the same server and service because I can find it on the server with netstat -an.

If I execute an invalid command, eg, "XYZZY /", I get the Tomcat error page, and an entry in the logs. But valid commands do not return any response, and do not show up in the logs.

Things I have done previous to posting here:

So how do I get Tomcat7 to start returning responses to the remote client?

server.xml (this was original 8080, but I changed it to test if it was a port conflict):

<Connector port="8085" protocol="HTTP/1.1" connectionTimeout="20000" URIEncoding="UTF-8" />

setenv.sh (based off of responses from previous questions that sounded vaguely similar; forces urandom for entropy, and IPv4 addresses):

JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true -Djava.security.egd=file:/dev/./urandom"

Local test:

xxx@xxx:~$ sudo /etc/init.d/tomcat7 restart
[ ok ] Restarting tomcat7 (via systemctl): tomcat7.service.
xxx@xxx:~$ telnet xxx 8085
Trying xxx...
Connected to xxx.
Escape character is '^]'.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <title>Apache Tomcat</title>

<h1>It works !</h1>
<snipped for brevity>
Connection closed by foreign host.

Remote test:

$ telnet xxx 8085
Trying xxx...
Connected to xxx.
Escape character is '^]'.
Connection closed by foreign host.

If instead of GET /, I issue XYZZY /:

$ telnet xxx 8085
Trying xxx...
Connected to xxx.
Escape character is '^]'.
<html><head><title>Apache Tomcat/7.0.68 (Ubuntu) - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 501 - Method XYZZY is not implemented by this servlet for this URI</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Method XYZZY is not implemented by this servlet for this URI</u></p><p><b>description</b> <u>The server does not support the functionality needed to fulfill this request.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.68 (Ubuntu)</h3></body></html>Connection closed by foreign host.

So again I know that I am connecting to Tomcat.

If I do connect remotely but do not immediately issue a command, but instead on the local machine execute netstat -an | grep 8085, I get:

xxx:~$ netstat -an | grep 8085
tcp        0      0  *               LISTEN
tcp        0      0 xxx:8085                yyy:52329               ESTABLISHED

Where yyy is my remote address, so I know that the connection is occurring correctly.


Disappointingly, the problem was a firewall doing port verification and thus killing the requests. So anything starting with "GET " was being blocked outbound, which is why I was seeing the results I did. Changed it to port 80 and suddenly everything works.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.