WebSocket ERR_CONNECTION_TIMED_OUT after activating SSL from cloudflare


First my website was loading over http and websocket connection was made over ws like this:

conn = new WebSocket('ws://myDomain:8080');

and everything was working fine and connection was made successfully

then I tried cloudflare’s SSL and now my website loads over https an so I changed the ws to wss like this:

conn = new WebSocket('wss://myDomain:8080');

now i get this error:

WebSocket connection to 'wss://myDomain:8080/' failed: Error in
connection establishment: net::ERR_CONNECTION_TIMED_OUT

what is causing this? do i have to do do any configurations for nginx?
here is my nginx config:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /srv/mydir;

        server_name myDomain.com;

        location / {
                index index.html;

I would appreciate any help

Websocket: Unexpected response code: 525

8080 is an HTTP-only port on Cloudflare, you cant proxy HTTPS over it.


oh i’m really sorry That 8080 was the first thing that came to my mind to write as an example, i’m actually running it on port 8081 and i tried bunch of other ports


These wont work at all. Only the ones listed at https://support.cloudflare.com/hc/en-us/articles/200169156-Which-ports-will-Cloudflare-work-with-