I have my tomcat server set up and it works on LOCAL-HOST, however I can't run it externally. Do I have to change some settings? I tried everything but it doesn't seem to work else where... It is weird because it works perfectly fine on local host.
-
1You are going to provide a bit more information. Why can't you run it externally? Is there an error message? What does "externally" actually mean? Is it just tomcat that's having issues, or is it a web app you have written? – stringy05 Apr 27 '15 at 01:18
-
when I say externally, I mean like on other machines.... it works on localhost, but when i try it on different machine using server's ip address, it doesnt work @stringy05 – user3100209 Apr 27 '15 at 02:39
-
2well you still haven't supplied any details like error messages or the like but I'm going to go out on a limb and say your tomcat is only listening on localhost instead of the network IP. Check your "address" setting in server.xml and use either the hostname or 0.0.0.0, similar to this: http://stackoverflow.com/questions/6246127/cant-access-tomcat-using-ip-address – stringy05 Apr 27 '15 at 02:48
-
Well, assuming that tomcat runs more or less in default configuration, it should not be a big deal to get it working on a remote host. It could also be the firewall of the target host that denies the access. Did you check if the port used by Tomcat (default 8080) is open for access on the remote host? – gemue Apr 28 '15 at 05:55
-
@stringy05 this if my first time doing spring/tomcast, i only have pom.xml ... i do not see server.xml... and there is no error. This is what i do "mvn spring-boot:run" and then when i do https://localhost:8080, it works but now when i go on a different machine on which my server is not running and i use my server's computer IP and do https:xxx.xxx.xxx.:8080 , this should work but the page doesnt even load – user3100209 Apr 28 '15 at 15:30
-
@gemue How do i check the tomcast port to see if its open for access on remote host? sorry i am new to this and i have no clue. – user3100209 Apr 28 '15 at 15:33
-
The port is usually set in
/conf/server.xml which contains by default a – gemue Apr 29 '15 at 08:51element. I usually configure the firewall via webmin because the tooling depends on the distribution. On openSUSE for instance it can also be configured via YaST.
1 Answers
So you are running tomcat within a spring boot app, started from the maven spring boot plugin and it listens on localhost but can't be reached using your LAN IP address.
Just a note - people on SO are keen to help but it shouldn't be a treasure hunt to get the necessary information.
First
Check which IP address and port tomcat is listening on: the spring boot log will usually tell you the name of the host, eg mymac.local, and the port will be shown, port(s): 8080 (http), :
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.3.RELEASE)
2015-04-29 09:14:33.269 INFO 7031 --- [main] hello.Application Starting Application v0.1.0 on mymac.local with PID 7031 (/Users/foo/Development/java/springframework/gs-spring-boot/complete/target/gs-spring-boot-0.1.0.jar started by foo in /Users/foo/Development/java/springframework/gs-spring-boot/complete)
2015-04-29 09:14:35.072 INFO 7031 --- [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-04-29 09:14:35.506 INFO 7031 --- [main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-04-29 09:14:35.507 INFO 7031 --- [main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.20
And as a rule tomcat starts listening on all IP addresses (0.0.0.0) so it's odd this doesn't work for you.
Another way to do this is with netstat
. For Max/Linux:
$ netstat -an | grep 8080
tcp46 0 0 *.8080 *.* LISTEN
On windows
C:\> netstat -an | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING
TCP [::]:8080 [::]:0 LISTENING
If your app is listening on 0.0.0.0 or a real IP like 192.168.0.100 or something then you are likely getting firewalled or blocked on the network somehow.
If your app is listening only on localhost/127.0.0.1 then you need to tell tomcat to use the real IP, like this question: How to configure embedded Tomcat integrated with Spring to listen requests to IP address, besides localhost?
Secondly Do a basic connectivity with a simple client like curl/telnet/netcat. Browsers, especially IE, may be subject to restrictions like Windows Group Policy, that will prevent many things working with little or no information.
So on a different machine, see if you can telnet to the tomcat port (assuming tomcat is running on 192.168.0.100):
$ telnet 192.168.0.100 8080
Trying 192.168.0.100...
Connected to localhost.
Escape character is '^]'.
If you see the Connected message then you have connectivity, so if it's not working from the browser then there is something else wrong.
If it is refused right away then there is no route / connection between the 2 computers. This usually means your tomcat is not listening on the correct IP address
$ telnet 192.168.0.100 8080
Trying 192.168.0.100...
telnet: connect to address 192.168.0.100: Connection refused
telnet: Unable to connect to remote host
If it just hangs on the connecting message then it's probably a firewall.
$ telnet 192.168.0.100 8080
Trying 192.168.0.100...