Configuring Tomcat to Listen on Multiple Ports

By default, Tomcat listens on port 8080. However, if you want to configure Tomcat to listen on say, port 8081 as well, follow the steps below:

  1. Edit the server.xml file in the <CATALINA_HOME>\conf directory on the eG manager host.
  2. Look for the following lines in the server.xml file:

    <Connector port=”8080” protocol=”HTTP/1.1”

    connectionTimeout=”20000”

    redirectPort=”5443” />

  3. Replace the above-mentioned lines with the following lines:

    <Connector port=”8080”
    maxThreads=”150” minSpareThreads=”25” maxSpareThreads=”75”
    enableLookups=”false” redirectPort=”8443” acceptCount=”100”
    debug=”0” connectionTimeout=”20000”
    disableUploadTimeout=”true” />

    <Connector port=”8081”
    maxThreads=”150” minSpareThreads=”25” maxSpareThreads=”75”
    enableLookups=”false” redirectPort=”8443” acceptCount=”100”
    debug=”0” connectionTimeout=”20000”
    disableUploadTimeout=”true” />

    Upon startup, Tomcat will parse the server.xml file and create objects based on the content of the file. A single Connector element specification in the server.xml file will hence cause Tomcat to create a Connector object. If you then update the file with another Connector element specification, it will automatically trigger the creation of another instance of the Connector. This is how the above change creates two connectors listening on port 8080 and 8081 respectively. You only have one container though. The connectors create a request and response object for each incoming HTTP request and pass it to the container.

  4. Then, save the file.
  5. Finally, restart the Tomcat server.