Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there preferred alternate ports for Tomcat installations?

Tags:

tomcat

The default port for Tomcat (and other "secondary" web servers/servlet containers) is 8080.

If there are multiple services configured for this port or there is a need to install multiple instances of Tomcat on a server then you can can edit this port value in ${CATALINA_HOME}/conf/server.xml.

Is there a standard for determining what port number(s) that other installations should use? Is there a standard +1/+10/+100/+1000 approach that is typically followed? Is there a way to determine if there is conflicts without picking something and just trying it?

Also, in server.xml, there is by default:

<Server port="8005" shutdown="SHUTDOWN"> 
<Connector port="8080" protocol="HTTP/1.1" redirectPort="8443" /> 
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

For additional Tomcat installations, do all of these need to be renumbered/included? Should they each follow the same renumbering strategy?

like image 275
GeoGriffin Avatar asked Feb 13 '12 22:02

GeoGriffin


People also ask

What ports can be used for Tomcat?

By default the tomcat binding ports are 8005, 8080 and 8009. If you have another tomcat instance running on same server or other application like JBoss Application Server, these ports are likely already used.

On which port does Tomcat set by default?

With the default configuration, Apache Tomcat will listen for requests on port 8080. To use a different port, edit the server.


2 Answers

Is there a way to determine if there is conflicts without picking something and just trying it?

The latest version of Tomcat 7.0.25 includes functionality to automatically find and bind to a free port. This isn't great for any kind of production installation but is pretty neat for testing and development purposes.

To answer your original question, I quite like 9090 when 8080 is taken but I'm not aware of any specific best practice in this area.

The Tomcat docs which describe auto port binding are here.

And yes, all the other ports will need to be changed as well.

like image 129
Alex Barnes Avatar answered Oct 10 '22 13:10

Alex Barnes


If you bind multiple tomcats on the same IP address, you will need to use different ports on the connectors, and set them manually in the server.xml file.

I always used +1 by personnal convention.

like image 38
Jf Beaulac Avatar answered Oct 10 '22 13:10

Jf Beaulac