Fetch works locally, goes 522 when deployed
I would reaally appreciate some help when it comes to fetching an external API from inside of a Cloudflare Worker.
My API is running with Express at the url https:/[redacted].hstgr.cloud:3000/ and when I do fetch that locally, I get a proper response which is a JSON with a "message: Request Accepted!" - you see that in the browser.
So this works everywhere except inside a Worker:
const response = await fetch(
'https://[redacted].hstgr.cloud:3000/'
)
Inside a worker, it goes 522 and I can't get any info on it.
I tried messing up with nginx configs, disabled ufw, disabled Hostinger's Firewall, and also whitelisted Cloudflare IPs in my VPS machine.
Anything else I should look for?
3 Replies
Where is your worker running, on what hostname?
Workers have outbound port restrictions:
zone refers to anything under "website" in cloudflare. Your workers.dev is its own zone
hstgr.cloud isn't using CF DNS so I assume it's not in your account/not where the worker is running on, meaning your requests are all going to 443 https