Worker with url in search query timing out with 522

I have a worker that takes in a URL as search query and expected to return an svg.
This works within quick-edit section.

the worker takes in a url as search query and fetch data from the said url and returns an svg badge.
You can try here:

I’ve also tried with encoding the source param.

When going through the browser, I get 522 Connection timed out.
When I use the quick-edit section in the worker, this works as expected.

I want to find out where this is failing and how to fix it.

Thank you.

Hello, @suntharesan.mohan what’s the link?

Error 522: connection timed out

Error 522 occurs when Cloudflare times out contacting the origin web server. Two different timeouts cause HTTP error 522 depending on when they occur between Cloudflare and the origin web server:

  1. Before a connection is established, the origin web server does not return a SYN+ACK to Cloudflare within 15 seconds of Cloudflare sending a SYN.
  2. After a connection is established, the origin web server doesn’t acknowledge (ACK) Cloudflare’s resource request within 90 seconds.

An HTTP 524 error occurs if the origin web server acknowledges ( ACK ) the resource request after the connection has been established, but does not send a timely response.


Contact your hosting provider to check the following common causes at your origin web server:

  • (Most common cause) Cloudflare IP addresses are rate limited or blocked in .htaccess, iptables, or firewalls. Confirm your hosting provider allows Cloudflare IP addresses.
  • An overloaded or offline origin web server drops incoming requests.
  • Keepalives are disabled at the origin web server.
  • The origin IP address in your Cloudflare DNS app does not match the IP address currently provisioned to your origin web server by your hosting provider.
  • Packets were dropped at your origin web server.

If none of the above leads to a resolution, request the following information from your hosting provider or site administrator before contacting Cloudflare support:

  • An MTR or traceroute from your origin web server to a Cloudflare IP address that most commonly connected to your origin web server before the issue occurred. Identify a connecting Cloudflare IP recorded in the origin web server logs.
  • Details from the hosting provider’s investigation such as pertinent logs or conversations with the hosting provider.

the link is

Ok for one, is your origin web server overloaded and/or dropping connections? Show me analytics from that worker
If you’re the owner of this website:

Contact your hosting provider letting them know your web server is not completing requests. An Error 522 means that the request was able to connect to your web server, but that the request didn’t finish. The most likely cause is that something on your server is hogging resources. Additional troubleshooting information here.
Also have you deployed the worker?

Looking at the analytics and metrics from worker,
I don’t think any request even reached the worker.

Whoa! Did you see that spike? There was 1 request now 336 total requests! How long apart did you take these screenshots?

All screenshots taken within 10 mins
First one is just the worker. The other one is all traffic. I have 2 workers running one is working fine.

What about analytics by DNS code, just simply press DNS on the analytics page to find out and send me a screenshot of the results.

Hmm… Seems to be a high number of requests at around 9:35 (38 requests) then it goes down and comes back up at I’m guessing around 9:38 at (35 requests). Maybe the high number of request have something to do with it? Are there any blocked connections?

That was probably me trying to debug in the quick-edit. There are no blocked connection. The issue seem to be that the request for doesn’t make it to the worker at all.

What about firewall rules? Maybe one of the rules you’ve configured for the worker is causing conflict?

No firewall rules.

I’m going to try redeploying same worker in another url path to see if that has any effect

Anything else you realise?

So I had the routes configured as without trailing slash. I’ve added a new route with trailing slash. the route with trailing slash works. But even though is part of the routes, it still throws 522.

Try turning off or disabling the additional routes to see if it’s the worker itself or the additional routes that are causing the 522