Socket io doesnt connect only in cloudflare

I have setup a socket io server and when client makes request it shows that the client connected but in client it throws an error but using localhost or https://ip:port it works.
I have enabled Websockets in network tab, I have valid ssl certificates both on Cloudflare and server.

My website url: and you can test it

Your backend server (the one running the server) is returning a 403 - unauthorized
It looks like this may be because has an “origin” setting where you specify the origins which are allowed to use your websocket server.
I found these posts on topic:
javascript - Have issues with socket io on backend connecting with my quasar app. Code 403(Forbidden) error with Socket io - Stack Overflow
websocket - Socket IO forbidden 403 - Stack Overflow
Either way, it seems the problem is with your origin web server, and not Cloudflare. It only shows on Cloudflare because your websocket server sees your website as an unauthorized origin.

Hello! I tested the socket Io again but it doesn’t seem to return any status, but I have setup that connects with plain websocket, i have fixed any origin errors but still it doesn’t connect to websockets

I have tested the site in and everything works, but doesnt in Cloudflare.

The problem I see now is the port. Your website behind Cloudflare is trying to connect to a web socket on wss://

That is not one of Cloudflare’s supported ports:

Even forcing it to normal https/443 doesn’t work, so I’m guessing you’re running the server on a separate port? (Not familiar with
You could put it behind a reverse proxy like nginx, looks like they have guides for that:
You could also try making an origin rule rewrite the destination port based on the path.

Edit: Looking at again, the working example you gave is on the same port. I wonder if it’s something as simple as fixing the port issue, and making sure you have Websockets enabled within Cloudflare (Network → Websockets).

Hello! Yes, I have enabled websockets in the network tab.

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