Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having trouble setting up tomcat6 with 2 virtual hosts, behind apache2.

if i have just one host defined in tomcat, and one jk worker, everything works fine. as soon as i define another jk worker and a corresponding tomcat host i get this error in jk.log:

9:3075328656] [info] ajp_connect_to_endpoint::jk_ajp_common.c (922): Failed opening socket to ( (errno=111)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [error] ajp_send_request::jk_ajp_common.c (1507): (dogself) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [info] ajp_service::jk_ajp_common.c (2447): (dogself) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [error] ajp_service::jk_ajp_common.c (2466): (dogself) connecting to tomcat failed.
[Tue Feb 08 03:08:13 2011] [17159:3075328656] [info] jk_handler::mod_jk.c (2615): Service error=-3 for worker=dogself

my tomcat server.xml looks like this:

<Service name="Catalina">

<Connector port="8080" protocol="HTTP/1.1" 
           redirectPort="8443" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<Engine name="Catalina" defaultHost="">

  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

  <Host name=""  appBase="webapps-dogself"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">

  <Host name=""  appBase="webapps-test"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">


my looks like this:

# - ajp13
# List workers

# Define dogself


tomcat is started/restarted

i followed these directions for setting it up:

can someone confirm that it would work as above?

share|improve this question

You will need to add another Connector on a different port for the second virtual host, because the AJP connection between Apache and Tomcat is a persistent connection.

eg, server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />


share|improve this answer
ok, then are you saying that the answer here is wrong:… – mkoryak Feb 8 '11 at 17:46
daveadam's answer will work. We had recently configured 3 virtual hosts in apache connecting to tomcat. Connector port has to be different for each separate worker. You can specify ports like 8009, 8010 and 8011 for 3 virtual hosts for example and so on. – tushar Aug 23 '12 at 8:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.