Search code examples
linuxapachetomcatapache2mod-jk

mod_jk not able to connect Apache and tomcat


I am not able to connect my Apache to tomcat servers. Below are the version details. mod_jk/1.2.39 Apache-2.4.41 tomcat-9.0.31

I have created Workers.properties file and mentioned my hostname and AJP port i.e. 8009 and also enabled Ajp connectors from tomcat side. Issue I am facing is mod_jk is not connecting to host that I have provided in workers.properties file. Instead of that it is connecting to 0.0.0.0. Below is the error from mod_jk.log

[Wed May 27 12:52:00 2020] [6902:140379841652544] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.39 initialized
[Wed May 27 12:52:00 2020] [6903:140379841652544] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.39 initialized
[Wed May 27 12:53:20 2020] [6906:140379663890176] [info] jk_open_socket::jk_connect.c (735): connect to 0.0.0.0:8009 failed (errno=111)
[Wed May 27 12:53:20 2020] [6906:140379663890176] [info] ajp_connect_to_endpoint::jk_ajp_common.c (1019): Failed opening socket to (0.0.0.0:8009) (errno=111)
[Wed May 27 12:53:20 2020] [6906:140379663890176] [error] ajp_send_request::jk_ajp_common.c (1659): (tomcat1) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)

I have checked I can access my tomcat servers and it's running fine. Below is the Ajp connectors from tomcat server

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

Is there anything I am missing or is it some kind of fat bug involve with this version of mod_jk? Any kind of Suggestion and Help will be appreciated.

Thanks, Anshu


Solution

  • Start tomcat server on IP address instead of 0.0.0.0.

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

    Use tomcat-adress and Port in worker.properties. Restart tomcat and Apache service. Also make sure that port 8009 is open between Apache and tomcat server.