# Haproxy random and rare 503 and 504 error

**URL:** <https://discourse.haproxy.org/t/haproxy-random-and-rare-503-and-504-error/4392>\
**Category:** Help!\
**Created:** [October 15, 2019, 1:53pm UTC](https://discourse.haproxy.org/t/haproxy-random-and-rare-503-and-504-error/4392 "2019-10-15T13:53:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amine97](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Amine97](https://discourse.haproxy.org/u/Amine97)\
**Post date:** [October 15, 2019, 1:53pm UTC](https://discourse.haproxy.org/t/haproxy-random-and-rare-503-and-504-error/4392/1 "2019-10-15T13:53:52Z")

</div>

this is my Haproxy cfg,

sometimes i get randomly and rarely “503 service unavailable no server is available to handle this request” and rarely also “504 Gateway Time-out The server didn’t respond in time.”

in haproxy Logs:

1. stats stats/ 0/-1/-1/-1/0 503 212 - - SC-- 2/2/0/0/0 0/0 “GET /favicon.ico HTTP/1.1”

2. front\_app~ back\_app/srv\_app 0/0/0/-1/60002 504 194 - - sH-- 4/3/0/0/0 0/0 “GET / HTTP/1.1”

once i reload the page it works …

any help please ?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/haproxy/original/1X/6e996c50a7507fba8e68d98690d418e277602738.jpeg)

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [October 15, 2019, 2:48pm UTC](https://discourse.haproxy.org/t/haproxy-random-and-rare-503-and-504-error/4392/2 "2019-10-15T14:48:07Z")

</div>

As per the documentation:

> sH The “[timeout server](https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#timeout%20server)” stroke before the server could return its response headers. This is the most common anomaly, indicating too long transactions, probably caused by server or database saturation. The immediate workaround consists in increasing the “[timeout server](https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#timeout%20server)” setting, but it is important to keep in mind that the user experience will suffer from these long response times. The only long term solution is to fix the application.

---

<div class="post-metadata">

**Author:** ![Amine97](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Amine97](https://discourse.haproxy.org/u/Amine97)\
**Post date:** [October 15, 2019, 8:43pm UTC](https://discourse.haproxy.org/t/haproxy-random-and-rare-503-and-504-error/4392/4 "2019-10-15T20:43:54Z")

</div>

Thank you for helping… But I tried both increasing to 50s 100s even 200s and still getting same error messages … Also i decreased the values to 10s 8s 6s…at first it worked fine and the apps opened faster then again the same error messages… By th way i set the same config above for other applications and it worked like a charm 😕 …
