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

Apache2 reverse proxy seems to intermittently freeze when proxying a tomcat web app.

The problem is that every so often (once or twice a day usually after inactivity) when I try to log into this proxied web application it just freezes. The application just freezes indefinitely, no 500 response code... the browser just waits and waits.

If I keep trying to hint the web address from my browser it will eventually just start working again.

Ive tried to reproduce this issue by navigating directly to the web app on tomcat port 8080, but ive never been able to reproduce this without going through the reverse proxy.

Here is my reverse proxy config... any fault finding ideas? thanks


ProxyPass /manage/ http://localhost:8080/manage/
ProxyPassReverse /manage/ http://localhost:8080/manage/

ProxyPass /manage http://localhost:8080/manage
ProxyPassReverse /manage http://localhost:8080/manage


  <IfModule mod_proxy.c>
    #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.

        ProxyRequests Off

        <Proxy *>
                AddDefaultCharset off
                Order deny,allow
                Deny from all
                Allow from all

        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On

More info: (not sure if relevant)

Enabled apache modules:

core_module (static) log_config_module (static) logio_module (static) mpm_worker_module (static) http_module (static) so_module (static) alias_module (shared) auth_basic_module (shared) authn_file_module (shared) authz_default_module (shared) authz_groupfile_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) cgid_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) mime_module (shared) negotiation_module (shared) proxy_module (shared) proxy_ajp_module (shared) proxy_connect_module (shared) proxy_http_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) status_module (shared)

Update: I am now using the ajp protocol for the proxy. An have set some addition ProxyPass config e.g.

ProxyPass /manage ajp://localhost:8009/manage max=20 ttl=120 acquire=10000 retry=0
ProxyPassReverse /manage ajp://localhost:8009/manage
share|improve this question
Any errors in error.log? Or in catalina.out. – Paul May 8 '11 at 7:50
No errors in catalina.out but there is an interesting entry the appears every now and then in error.log [Sat May 07 07:27:59 2011] [error] (111)Connection refused: proxy: HTTP: attempt to connect to (localhost) failed [Sat May 07 07:27:59 2011] [error] ap_proxy_connect_backend disabling worker for (localhost) – tinny May 8 '11 at 8:21

I would try to use ajp to connect to tomcat from apache.
Please test the configuration using mod_proxy_ajp with Tomcat.
From logs, it looks like the tomcat did not responded to apache's request. It refused the connection.

If you have high traffic, search deeper in your application's logs. It could be a deadlock or maxthreads reached.


share|improve this answer
Ive setup proxying using the ajp protocol. I did a bit of reading, sounds like a much better protocol for between apache and tomcat. Not sure if this will solve my problem. Time will tell. Thanks – tinny May 9 '11 at 11:50
Nope, didn't solve the problem. Still get intermittent freeze when using reverse proxy. Connecting directly to Tomcat (port 8080) is working well – tinny May 10 '11 at 12:20
Any errors in apache's logs (error.log or vhost's error logs)? – Paul May 10 '11 at 14:14
How many httpd processes do you have running when is not working? Count them with: ps ax | grep httpd | wc -l – Paul May 10 '11 at 14:38
No vhost error logging. I do have a few "Connection refused: proxy:" in error.log but I now think this was only from times when I restarted tomcat – tinny May 11 '11 at 2:51

Check that your apache file cache is disabled.

# LoadModule file_cache_module modules/

If that doesn't solve the problem (shouldn't, this doesn't seem a cache problem) try debugging using mod_jk. Download appropiate mod_jk version for your Apache, setup it and set the log level to DEBUG

# Set the jk log level [debug/error/info] 
JkLogLevel          debug

Also, include tons of info in your apache logs

LogFormat "%h %l %u %t \" %m \"%V\" \"%r \" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D CustomLogFormat
. . .
CustomLog "|C:/Apache2/bin/rotatelogs.exe C:/Apache2/logs/access_%Y%m%d.log 86400" CustomLogFormat

You should now have an Apache log with microseconds taken to serve the page, and a debug-level log of your AJP 1.3 connection to tomcat (with mod_jk).

With that done, restart apache and try forcing that freezing error. When error happens, check time, and browse logs to see what happened in that instant, how much time did apache spend processing, and so.

It won't solve anything, but most possibly will give you some insight on what is happening.

share|improve this answer
No file cache module. Ive added a list of enable modules to my original post. – tinny May 15 '11 at 10:33

If you are getting a connection refused you may be hitting the maxthread count on Tomcat. What is maxclient set to for Apache? What is maxthread set to on Tomcat? You want to make sure your maxclient doesn't exceed maxthread. If not Apache will attempt to proxy more connection than Tomcat can serve and Tomcat will refuse connections.

Also if you retry=0 to the end of your ProxyPass statements Apache won't disable the backend worker and your recovery when this problem is encountered will be faster.

share|improve this answer
maxClient in apache 150, maxThread in tomcat not set but defaults to 200 (I have now explicitly set it to 200 in my ajp connector). I will try retry=0 – tinny May 11 '11 at 2:47
BTW I am the only user of this server right now. Very very low traffic. – tinny May 11 '11 at 2:52
Is it always after a period of inactivity? If so then you may be running into a situation where you are exceeding the tcp connection timeout setting for your OS. You may want to try setting a ttl timeout on your ProxyPass statements. For instance ttl=120 will cause inactive connections to not be used again after being inactive for 120 seconds. – TimS May 11 '11 at 3:49
Not sure about the period of inactivity anymore. Seems to sometimes happen after a short period of use. Although it does seem to become more stable during longer periods of use (if that makes sense???). Either way I think an explicitly defined ttl is a good idea. Thanks – tinny May 11 '11 at 4:09
Another thing ive noticed is that the application is much more responsive when accessed through the proxy (when its not frozen). Is apache doing any caching? – tinny May 11 '11 at 4:32

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.