5

We hire a Virtual MS Server 2008 machine from a hosting company. I say this because maybe it's got a bunch of extra settings that aren't the "vanilla" 2008 settings.

Anyway, I installed a default installation of Tomcat 6.0, and have got it running all good on the server.

I can access it via localhost:8080, or xxx.xxx.xxx.xxx:8080.

However, when I try and access this from machine at home using the static IP address it doesn't work. why?

I thought it might have been the Windows firewall so I create a new inbound rule for port 8080.

still doesn't work, I just get nothing from the browser, like it can't connect to that IP address.

However, when I put just the IP address (i.e. port 80), it resolves the DNS fine and goes to our ASP.NET IIS app... so, what's wrong?

UPDATE:

here's my tomcat server.xml:

    <?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">

  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443"
               URIEncoding="UTF-8"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->        

      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
        -->

      </Host>
    </Engine>
  </Service>
</Server>
2
  • Have you checked if there are any external firewalls at your hosting provider? Maybe they are blocking port 8080, and not port 80. An easy way to test would be to make tomcat listen on port 80, and see if it responds.
    – Frederik
    Jul 10, 2012 at 6:06
  • Thanks for all answers. For me it was a different issue. I had to set my wireless network to "private". I only need tomcat for network internal use. For some reason although firewall rule was set to allow for all, it does not allow access from within the same network if set to public. Jan 15, 2021 at 8:51

3 Answers 3

10

You have to tell the Connector in the server.xml file that you want to use it on every address not only on 127.0.0.1 by changing the address attribute's value to 0.0.0.0

<Connector port="8080" protocol="HTTP/1.1" 
           maxHttpHeaderSize="65536" 
           connectionTimeout="20000" 
           redirectPort="8443"
           address="0.0.0.0" />

Shutdown and startup the tomcat after that

See also: http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

3
  • Thanks for the answer yunzen. I'd love to see this as the answer but this was so long ago I don't know how to even replicate the issue to see if your solution works... :-/ I could try setting up Apache on a windows virtual machine....
    – andy
    Nov 4, 2014 at 22:22
  • @andy there exists a TYPO3 extension named solr which contains an install script which installs tomcat and solr automatically. forge.typo3.org/projects/extension-solr/wiki/Setup_on_*NIX
    – yunzen
    Nov 4, 2014 at 22:25
  • This is the solution that has worked for me several times.
    – sleeves
    Jan 17, 2015 at 20:14
3

Have you actually enabled Tomcat to listen on the eth0 port, rather than just the localhost port. If you can just access it via the localhost (even when you type in the IP addresses it still goes to the local host) but not externally, this is normally the case.

<Host name="www.example.com" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="."/>

Put this after the other host line but before the line, but remember to change the domain to the domain name your are connecting to it by.

4
  • cool, i think that's it. but what do you mean? could you provide a step by step? How do I enable tomcat to do this? cheers!
    – andy
    Dec 31, 2009 at 5:05
  • check you didn't explicitly tell tomcat to listen only on 127.0.0.1:8080, this is configurable by address field of http connector in server.xml: tomcat.apache.org/tomcat-5.5-doc/config/http.html Dec 31, 2009 at 5:14
  • @stephen. hey stephen, just posted my current server.xml. I'm specifying a specific address.... should I be? cheers
    – andy
    Dec 31, 2009 at 9:31
  • @stephen. hey stephen, tried that, but still nothing...?
    – andy
    Jan 8, 2010 at 0:57
3

For future visitors: I had a similar problem on a Linux server and none of the "solutions" I've found helped.

Finally, I found that I just had firewall settings that blocked that port.

4
  • sudo ufw disable Mar 3, 2015 at 22:23
  • The OP says, that he has open inbound 8080; what do you mean by "that port" and "none of the solutions worked"? The "sudo ufw disable" of the other comment is just a joke, I guess.
    – P Marecki
    Nov 4, 2015 at 19:36
  • This answer is meant as another (stupid) thing on the list of things to check when you can't access tomcat externally. I specifically said "For future visitors", implying that this isn't meant to solve OP's problem, but maybe help others coming here from Google.
    – itsadok
    Nov 5, 2015 at 14:51
  • Instead of disabling firewall you can allow that port, ufw allow 8080 or ufw allow 8080/tcp
    – Alfran
    Oct 21, 2020 at 10:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .