# Haproxy is swallowing 500 errors

**URL:** <https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202>\
**Category:** Help!\
**Created:** [January 29, 2021, 5:02pm UTC](https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202 "2021-01-29T17:02:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![longschlong](https://avatars.discourse-cdn.com/v4/letter/l/f9ae1b/32.png) [@longschlong](https://discourse.haproxy.org/u/longschlong)\
**Post date:** [January 29, 2021, 5:02pm UTC](https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202/1 "2021-01-29T17:02:37Z")

</div>

Hi, when HAProxy rec vies a 500 from a backend it will respond with 502 to the client. Is there any way to prevent this and just forward the 500 response?

---

<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:** [January 29, 2021, 10:42pm UTC](https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202/2 "2021-01-29T22:42:35Z")

</div>

> [@longschlong](#):
>
> Hi, when HAProxy rec vies a 500 from a backend it will respond with 502 to the client.

That’s not expected behavior, however it is more likely that one of the following cases apply:

> 502 when the server returns an empty, invalid or incomplete response, or when an “[http-response deny](https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#http-response%20deny)” rule blocks the response.

Check your configuration, check haproxy logs, issue `show errors` on the admin socket or capture the server response to check if it’s valid.

---

<div class="post-metadata">

**Author:** ![longschlong](https://avatars.discourse-cdn.com/v4/letter/l/f9ae1b/32.png) [@longschlong](https://discourse.haproxy.org/u/longschlong)\
**Post date:** [January 29, 2021, 11:11pm UTC](https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202/3 "2021-01-29T23:11:20Z")

</div>

Hi Lukas,

I produce the error code controlled. So I am able to test with any code I want. Well it turns out that I get the error page from the backend for every response.

```
<% response.sendError(501, "i dont like"); %>

```

![image](https://us1.discourse-cdn.com/flex016/uploads/haproxy/original/2X/e/e84b19783fb675dbbc03a824cbe81acbbf752ee9.png)

except when the status code is 500.

```
<% response.sendError(500, "test this"); %>

```

![image](https://us1.discourse-cdn.com/flex016/uploads/haproxy/original/2X/f/fe26614cbf652315d02e5edf6897b8601c9b3004.png)

---

<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:** [January 29, 2021, 11:20pm UTC](https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202/4 "2021-01-29T23:20:25Z")

</div>

Like I said:

haproxy logs, `show errors` on the admin socket and a full packet capture is required.

Also the entire haproxy configuration as well as the output of `haproxy -vv`.

---

<div class="post-metadata">

**Author:** ![longschlong](https://avatars.discourse-cdn.com/v4/letter/l/f9ae1b/32.png) [@longschlong](https://discourse.haproxy.org/u/longschlong)\
**Post date:** [January 29, 2021, 11:53pm UTC](https://discourse.haproxy.org/t/haproxy-is-swallowing-500-errors/6202/5 "2021-01-29T23:53:55Z")

</div>

Hi Lukas,

thanks for motivating me to dig deeper. The issue was that HAProxy would retry on 500 but there was no other server to retry.

```
retries 1
retry-on all-retryable-errors
option redispatch 1

```

When I comment those out I get the 500.
