# Haproxy custom error page does not always work

**URL:** https://discourse.haproxy.org/t/haproxy-custom-error-page-does-not-always-work/11848
**Category:** Help!
**Created:** [June 6, 2025, 3:43pm UTC](https://discourse.haproxy.org/t/haproxy-custom-error-page-does-not-always-work/11848 "2025-06-06T15:43:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![duffy](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@duffy](https://discourse.haproxy.org/u/duffy)
#### Post date: [June 6, 2025, 3:43pm UTC](https://discourse.haproxy.org/t/haproxy-custom-error-page-does-not-always-work/11848/1 "2025-06-06T15:43:56Z")

</div>

Hello  
In order to have customized error pages, I added some config into haproxy:  
http-errors defaulterrorpages  
errorfile 400 /etc/haproxy/errors/400.http  
errorfile 403 /etc/haproxy/errors/403.http  
errorfile 408 /etc/haproxy/errors/408.http  
errorfile 500 /etc/haproxy/errors/500.http  
errorfile 502 /etc/haproxy/errors/502.http  
errorfile 503 /etc/haproxy/errors/503.http  
errorfile 504 /etc/haproxy/errors/504.http

frontend fe\_dmz  
bind \*:80  
bind [::]:80  
bind \*:443 ssl crt /etc/haproxy/tls-certs/ alpn h2,http/1.1  
bind [::]:443 ssl crt /etc/haproxy/tls-certs/ alpn h2,http/1.1  
mode http  
option httplog

```
    errorfiles defaulterrorpages

```

…  
There is a backedn returns 403, but sometimes the customized page shows, sometimes the default 403 page appears.  
Then for some reason we modified our 403 page, haproxy returns 3 versions of 403 page now: the default one, the page before modification and the page after modification.  
It seems that there is a cache somewhere? Is it a default behavior of Haproxy?  
Thanks

---

<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: [June 10, 2025, 3:51am UTC](https://discourse.haproxy.org/t/haproxy-custom-error-page-does-not-always-work/11848/2 "2025-06-10T03:51:11Z")

</div>

If a backend returns a 403 error, that will be passed as is, always. The errofile directive matters only for errors that haproxy generates.

> [@duffy](#):
>
> haproxy returns 3 versions of 403 page now

Unless we are talking about the backend error page, this happens when haproxy was not properly reloaded/restart/stopped and you end up running with some older haproxy instances in parallel that sometimes get requests.

To solve this stop haproxy, killall haproxy and when you have confirmed with ps that no haproxy processes are running anymore, then you start haproxy again.

---

<div class="post-metadata">

### Author: ![duffy](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@duffy](https://discourse.haproxy.org/u/duffy)
#### Post date: [June 26, 2025, 2:52pm UTC](https://discourse.haproxy.org/t/haproxy-custom-error-page-does-not-always-work/11848/3 "2025-06-26T14:52:33Z")

</div>

Thank you for your reply  
I killed all haproxy processes manually and restart it, and the problem solved  
Best regards
