© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•2y ago•
3 replies
Raymond Camden

Scheduled worker gets an error in production, not locally

I have a scheduled task worker that does a fetch call to an API and then does some work with the results. This is all running fine locally. However, in production, when I make a fetch call to the remote API, I get: “error code: 521”. To be clear, the same fetch() call is run in dev versus production. On a whim, I then built a whole new Worker, HTTP based, copied and pasted the function that makes the fetch() call, and it works fine.

Here's the worker, https://github.com/cfjedimaster/cloudflareworkers-demos/blob/main/scratchworker/src/index.js, and here is (virtually) the same worker as a HTTP service that runs just fine: https://github.com/cfjedimaster/cloudflareworkers-demos/blob/main/getincidents/src/index.js

As I said, if I test locally, it's perfect.
GitHub
cloudflareworkers-demos/getincidents/src/index.js at main · cfjedim...
Repository for CF Workers demos/examples/etc. Contribute to cfjedimaster/cloudflareworkers-demos development by creating an account on GitHub.
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Error: Handler does not export a fetch() for scheduled worker locally
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Scheduled Worker - Unexpected 429s
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
10mo ago
How to test an email Worker locally?
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
13mo ago
Testing worker locally with an existing project
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago