# CloudFlare 522 and HAproxy

**URL:** <https://discourse.haproxy.org/t/cloudflare-522-and-haproxy/7859>\
**Category:** Help!\
**Created:** [July 26, 2022, 1:15pm UTC](https://discourse.haproxy.org/t/cloudflare-522-and-haproxy/7859 "2022-07-26T13:15:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![theap](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@theap](https://discourse.haproxy.org/u/theap)\
**Post date:** [July 26, 2022, 1:15pm UTC](https://discourse.haproxy.org/t/cloudflare-522-and-haproxy/7859/1 "2022-07-26T13:15:45Z")

</div>

Hello,

We use schema:

CloudFlare → HAProxy v.2.4.8 → Nginx-\> Tomcat → Application

Sometimes we see error 522 with our clients. Connection cannot be established. From the CF logs it is clear that the connection breaks for 15 seconds [https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors#522error](https://support.cloudflare.com/hc/en-us/articles/115003011431-Troubleshooting-Cloudflare-5XX-errors#522error)

1. Before a connection is established, the origin web server does not return a SYN+ACK to Cloudflare within 15 seconds of CloudFlare sending a SYN.

What logging for haproxy can be enabled to determine the cause. Is it internet packet loss or something else?

Thanks

---

<div class="post-metadata">

**Author:** ![simplexion](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/simplexion/32/1858_2.png) [@simplexion](https://discourse.haproxy.org/u/simplexion)\
**Post date:** [July 27, 2022, 11:25pm UTC](https://discourse.haproxy.org/t/cloudflare-522-and-haproxy/7859/2 "2022-07-27T23:25:04Z")

</div>

Why do you have an nginx server in the mix? I’d move that out the way and try again. I have an Apache Guacamole setup like this where the traffic flows like:

Cloudflare → HAProxy → Tomcat → Application

It works perfectly.

---

<div class="post-metadata">

**Author:** ![theap](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@theap](https://discourse.haproxy.org/u/theap)\
**Post date:** [July 28, 2022, 7:36am UTC](https://discourse.haproxy.org/t/cloudflare-522-and-haproxy/7859/3 "2022-07-28T07:36:05Z")

</div>

It was built before me. I don’t have an answer to that question. But your experience is interesting. We have this problem mainly from India. I suppose that sometimes for some reason the handshake becomes very slow.
