aspose file tools*
The moose likes Tomcat and the fly likes Can't access Tomcat 7 from network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Can Watch "Can New topic
Author

Can't access Tomcat 7 from network

Pete Grant
Greenhorn

Joined: Apr 25, 2011
Posts: 8
I just installed Tomcat 7.0.12 and it works, but only if I access it from localhost:8280 (8080 belongs to v 6.). From other computers on my LAN I get Server Not Found.

Apache 2 I have installed on same computer works just fine.

I have tried to do what the documentation says in section Remote Access Filter but I'm not sure which configuration to modify and what add so that I can allow at least 192.168.1.*. How do I do it?

TIA
Pete
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Welcome to JavaRanch, Pete Grant!

Have you tried accessing with the IP ("<IPaddress>:8280") form you local machine itself?

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Pete Grant
Greenhorn

Joined: Apr 25, 2011
Posts: 8
Yes, I have and it works just fine. I can access Apache 2, shared files/folders, a other programs from other machines except for Tomcat.
BTW, I had the same problem with Tomcat 6.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

That usually means that you need to punch a hole in the firewall for port 8280.


Customer surveys are for companies who didn't pay proper attention to begin with.
Pete Grant
Greenhorn

Joined: Apr 25, 2011
Posts: 8
The problem seems to be with Tomcat, not the server machine.

Test 1:
I changed the port (server.xml Connector port) to 96 and restarted Tomcat.
Result: No change; i.e. worked ok on local machine, could not access from others.

Test 2:
Stopped service on both Apache2 and Tomcat. Changed Tomcat's port to 88 (same as Apache's). (Note that Apache server has been working just fine for all machines on my LAN.
Restarted Tomcat but not Apache.
Result: Exactly the same.

Conclusion: The problem seems to be with Tomcat; most likely its setup.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

When you can access an Internet server locally, but not from anywhere else on the network, that's almost invariably a firewall problem. About the only other thing that could give that behavior is if the external address you're using doesn't actually point to the machine you think it does.

Only one application at a time can own a tcp/ip port. So if Apache is listening on port 88 and you attempt to start Tomcat listening on port 88 on the same machine, you should see a "port already in use" message in the catalina.out logfile. Note that this will NOT cause Tomcat to fail to start, but since it can't listen for requests, Tomcat's going to be pretty useless until you give it a port of its own.
Pete Grant
Greenhorn

Joined: Apr 25, 2011
Posts: 8
Maybe I wasn't clear about the tests I performed.

Test 1.
a) I edited the server.xml file and changed the Connector port to 96. It did not complain about the port being in used already.
b) I restarted Tomcat and typed in "http://localhost:96/" and it gave me the standard default home page.
c) I also invoked a project I'm working on and it performed properly.
d) I went to another computer and typed in "http://computername:96/" and got Server not found message

Test 2:
a) I stopped the Apache2 server.
b) I edited Tomcat's server.xml file, changing the Connector port to 88.
c) I restarted Tomcat7 server
d) I typed in "http://localhost:88/ and it gave me the standard Tomcat default home page.
e) I switched to another browser (Safari) which I haven't used since installing Tomcat7 and it worked as expected (this was to make sure that the browser had not cached the page).
f) I went to another machine and, once again, could not connect to the Tomcat server.

I restored the original ports for both Apache and Tomcat, restarted the services and I'm back where I started: I can connect to the Apache server from all the machines but Tomcat only from the localhost machine.

I have checked all the Tomcat logs and saw nothing unexpected, especially no "port already in use" entries. Lots of entries in localhost and localhost_acces logs.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

I'm going to have to reiterate that if you get a "server not found" browser message, there is no network path available, and that's almost always either a wrong network address or a firewall. Well, if the server is down, that will do it too, but I think we can rule that one out.

Apache2 is confusing the issue. The common scenario for Tomcat+Apache is that Apache2 serves as a proxy for Tomcat using a coyote connector to link Apache to Tomcat. That allows external apps to access Tomcat apps from the same port (generally port 80) that non-Tomcat requests are served under rather than making them ask for a non-standard port just for Tomcat.

However, the coyote connector does NOT use the Tomcat HTTP port to do that. It uses a jk-protocol port, by default port 8009. So changing port 8080 wouldn't be sufficient. You cannot meaningfully access port 8009 directly either locally or via the network. The jk protocol is a binary protocol and ordinary web browsers can't handle it. Not an issue, though, since mod_jk and Tomcat understand it, and they're the ones that need it.

If you are using Apache as a proxy to Tomcat, then a firewall opening must exist for Apache, but since the Tomcat requests are being forwarded through Apache, that doesn't require a firewall opening for Tomcat. For test purposes, I often access Tomcat directly as well, so I'll have the firewall open to 8080 or whatever, but in production, I block that port.

If you proxy through Apache, you do have to set up the rules that determine what gets forwarded to Tomcat and how. Still, I don't think that's the issue here, since as far as I can calculate, a failure in that area should result in a "404" error, not a Server Not Found. Server Not found, I think is actually generated in the browser itself when a network connection cannot be established.

The limitation that only one application may listen on a TCP/IP port is in TCP/IP itself, not Tomcat or Apache, so I have to conclude you never actually had both apps listening on the same port at the same time,

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't access Tomcat 7 from network
 
Similar Threads
setting tomcat port on www....
Tomcat cannot read web.xml
tomcat eclipse start issue
Tomcat as a Web Server
catalina.bat ans setclasspath.bath missing ... error while adding tomcat to netbeans IDE 6.9