Solving Apache 503 “Service temporarily unavailable” error

We had a problem with a customer that got a 1 minute timeout when restarting their DJango webapp, claiming that Apache did get stuck. After a test, in the Apache log files we found:

[Thu Oct 11 09:35:18 2012] [error] (111)Connection refused: proxy: HTTP: attempt to connect to 192.168.0.10:48880 (192.168.0.10) failed
[Thu Oct 11 09:35:18 2012] [error] ap_proxy_connect_backend disabling worker for (192.168.0.10)
[Thu Oct 11 09:35:19 2012] [error] proxy: HTTP: disabled connection for (192.168.0.10)
[...]

The problem is that the Apache proxy module, recognising that the service was unavailable, stopped redirecting requests to it for one minute.

The problem was solved adding a retry=0 parameter to the ProxyPass directive:

ProxyPass / http://192.168.0.10:48880/ retry=0 timeout=5
ProxyPassReverse / http://192.168.0.10:48880/

References: Apache mod_proxy documentation, Serverfault.com tip.

Advertisements

11 thoughts on “Solving Apache 503 “Service temporarily unavailable” error

  1. Hi Guys,

    This has been a huge help. I’m just curious should we still be seeing the below error in the apache error log after the change?

    [Wed Oct 02 03:33:18 2013] [error] ap_proxy_connect_backend disabling worker for (x.x.x.x)

    Regards,
    Steve

  2. Hi,
    I had the same problem on a RHEL 6. Even after applying the fix above the problem remained.
    Looking at the Apache log:

    . . .
    [Wed Feb 19 10:58:38 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
    [Wed Feb 19 10:58:38 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
    . . .
    [Wed Feb 19 10:58:59 2014] [error] ap_proxy_connect_backend disabling worker for (localhost)
    [Wed Feb 19 10:59:01 2014] [error] (13)Permission denied: proxy: HTTP: attempt to connect to 127.0.0.1:3000 (localhost) failed
    . . .

    I solved the problem by disabling SELinux
    setenforce permissive

    Thomas

    • you can check with audit2why (yum provides “*/audit2why”, then install that package) the selinux logs and enable booleans or create policies to allow Apache to connect to localhost:3000 :)

  3. Hi,

    I am getting the same issue on Windows 2012 machine. I can’t telnet localhost on port 8080 and there is no antivirus/windows firewall enabled.

    Please advise which conf file I should edit to add the required parameter in Windows 2012.

    Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s