Websocket with Cloudflare proxy closes connection instantly with code 1006
What is the issue or error you’re encountering I have create a Django app which run on a uvicron server on and AWS EC2. The EC2 is attached to a load balancer which is then connected to cloudflare proxy. If I remove cloudflare proxy, websockets work fine, even with SSL/TLS enabled, https, etc. But as soon as I turn on cloudflare proxy (orange cloud), the websocket conneciton instantly close upon opeing. They give 1006 error code which means nothing.
What steps have you taken to resolve the issue? I have looked at the logs, to see that the handshake is a successful. But when this reaches to the client, websocket disconnects, instanlty.
app-be | INFO: ('172.18.0.7', 58718) - "WebSocket /ws/debug/" [accepted]
app-be | INFO: connection open
app-fe | 10.2.0.231 - - [31/Aug/2025:12:47:26 +0000] "GET /ws/debug/ HTTP/1.1" 101 0 "-"
app-be | INFO: connection closed
app-be | [django] [INFO] [2025-08-31 13:17:53,550] WebSocket disconnected: 1006
I have even sent a message just after connection, in the logs I can see a message has been sent, but client never receives it.
I don’t know where do I go from here, I have:
- Websockets enabled on cloudflare
- I am sending a keep alive notification
- I have upgrade connection headers in my request.
Any help would be appreciated.