502 bad gateway for websocket connection randomly

What is the name of the domain?

offergenie.ai

What is the error number?

502

What is the error message?

bad gateway

What is the issue you’re encountering

I have a subdomain as an endpoint for websocket connection on Cloudflare.

What steps have you taken to resolve the issue?

The subdomain endpoint on Cloudflare worked well at the beginning for 1-2 days, but got bad gateway errors now. I also used Traefik to generate another URL for websocket service, that URL works well. During the time of error occurs, no code or config changes.
So one URL under Cloudflare has bad gateway errors, one URL under Traefik works well, and all other things are the same.
I verified the certificate on the machine, the status was ok. I tried to turn off the proxy of Cloudflare, but it doesn’t work as well.

And you’re using HTTPS also WSS, correct?
WebSockets feature is enabled at Cloudflare dashboard?

Is it port forwarding, or rather as a proxy?

If Cloudflare is Paused or proxy :orange: disabled :grey: , this sounds like there’s something to debug on the origin and configuration files I guess :thinking:

I think Traefik is a reverse proxy like Nginx, I use it to expose the websocket service in a docker container.

Yes, I use wss and https.

Yes, I turn on websocket on cloudflare( actually it is on by default, so I didn’t change it).

I tried to turn off proxy on Cloudflare but still got a 502 bad gateway error.

Does that 502 then come from the origin server? :thinking:

Sounds like the HTTP<->HTTPS not working well.

May I ask what SSL option have you got selected under the SSL/TLS tab at Cloudflare dashboard for your domain ( Flexible, Full, Full Strict … )? :thinking:

Wonder if any firewall blocking the Docker Container or if it’s service is listening on the needed ports.

This topic was automatically closed after 15 days. New replies are no longer allowed.