# Getting 502 errors randomly from HAproxy with SH code

**URL:** <https://discourse.haproxy.org/t/getting-502-errors-randomly-from-haproxy-with-sh-code/8403>\
**Category:** Help!\
**Created:** [February 14, 2023, 3:50am UTC](https://discourse.haproxy.org/t/getting-502-errors-randomly-from-haproxy-with-sh-code/8403 "2023-02-14T03:50:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![karishmasl](https://avatars.discourse-cdn.com/v4/letter/k/e274bd/32.png) [@karishmasl](https://discourse.haproxy.org/u/karishmasl)\
**Post date:** [February 14, 2023, 3:50am UTC](https://discourse.haproxy.org/t/getting-502-errors-randomly-from-haproxy-with-sh-code/8403/1 "2023-02-14T03:50:26Z")

</div>

I am randomly getting HAProxy 502 errors when I send request to my backend via haproxy.I have put retry on 502.But still I get 502 errors.  
I have installed HAProxy on a Ubuntu 18.04 system with 4 cores.  
The following is the termination code I get from haproxy logs  
502 209 - - SH–  
0/0/0/-1/0 which correspond to %TR/%Tw/%Tc/%Tr/%Ta

The following is the configuration.

global  
maxconn 256

defaults  
mode http  
timeout connect 10s  
timeout client 30s  
timeout server 30s  
timeout check 10s  
log global  
option httplog

frontend mywebapp  
bind \*:7801  
mode http  
option httplog  
default\_backend webservers

backend webservers  
mode http  
balance roundrobin  
retry-on 502  
retries 3  
server server1 10.92.89.57:7705 check  
server server2 10.92.89.58:7705 check  
server server3 10.92.89.59:7705 check
