Start two or more Tomcat instances on localhost machine


Codever Logo

(P) Codever is an open source bookmarks and snippets manager for developers & co. See our How To guides to help you get started. Public bookmarks repos on Github ⭐🙏


There are to main applications, that power Podcastpedia.org, one that is actually the web application and another one where I do administrative stuff and podcast updates. Experience has shown that if I want to run the podcasts updates in the background and do some testing/debugging/redployment on the front-end application it’s better to have them running on different Tomcat instances on the development machine.

How do I do that? It’s very easy. First make a copy of one instance and name it as you please:

Clone Tomcat directory

Clone Tomcat directory

After that go to the conf/server.xml file and modify the ports from the Connector entries:

original

.......
<Connector port="8080" protocol="HTTP/1.1"
		   connectionTimeout="20000"
		   redirectPort="8443" />
......
<!-- Define an AJP 1.3 Connector on port 8010 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
....

modified

.......
<Connector port="8081" protocol="HTTP/1.1"
		   connectionTimeout="20000"
		   redirectPort="8444" />
......
<!-- Define an AJP 1.3 Connector on port 8010 -->
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
....

And then start your two instances. Because I still get an java.net.BindException: Address already in use: JVM_Bind error:

27.11.2013 06:56:47 org.apache.catalina.core.StandardServer await
SEVERE: StandardServer.await: create[localhost:8005]:
java.net.BindException: Address already in use: JVM_Bind
	at java.net.PlainSocketImpl.socketBind(Native Method)
	at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:383)
	at java.net.ServerSocket.bind(ServerSocket.java:328)
	at java.net.ServerSocket.<init>(ServerSocket.java:194)
	at org.apache.catalina.core.StandardServer.await(StandardServer.java:427)
	at org.apache.catalina.startup.Catalina.await(Catalina.java:779)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:725)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)

it means I have forgot to change the port number from the Server entry:

default

<Server port="8005" shutdown="SHUTDOWN">

modified

<Server port="8006" shutdown="SHUTDOWN">

That’s it. You should now be able to run the two instances of Tomcat 7 with no trouble. If you want to start a third one and so one, follow the same procedure and use different port numbers.

Don’t forget to check out Podcastpedia.org – you might find it really interesting. We are grateful for your support.

Podcastpedia image

Adrian Matei

Creator of Podcastpedia.org and Codepedia.org, computer science engineer, husband, father, curious and passionate about science, computers, software, education, economics, social equity, philosophy - but these are just outside labels and not that important, deep inside we are all just consciousness, right?

Subscribe to our newsletter for more code resources and news

Adrian Matei (aka adixchen)

Adrian Matei (aka adixchen)
Life force expressing itself as a coding capable human being

routerLink with query params in Angular html template

routerLink with query params in Angular html template code snippet Continue reading