Fetch request returns 522 from deployed worker, works from local


I attempted to send a GET request to a specific port from workers, such as: http://myurl.com:8080/api/getdata. It worked fine in my local development environment, but not when deployed to Cloudflare, I got 522. After trying various methods, the only one that succeeded was DNS proxying my URL to a Cloudflare URL, like this: CNAME cloudflareurl myurl.com. Then, I set up an origin rule to redirect the request from my Cloudflare URL to the specific port. Why is this the case?

I’m really curious and I would like to leave this information here, because I couldn’t find anything when I was searching for this.

I realised in the meantime that it’s a known limitation, you can’t make a request from a worker to non standard ports (80,443). I think this should be part of the documentation and I can’t really see why is it working like this.