{"record":{"id":"7d002da569b11dfc","repo":"gchq/CyberChef","slug":"error-making-request-to-url-e-tostring","errorCode":null,"errorMessage":"Error making request to ${url}\n${e.toString()}","messagePattern":"Error making request to (.+?)\n(.+?)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/DNSOverHTTPS.mjs","lineNumber":117,"sourceCode":"            url = new URL(resolver);\n        } catch (error) {\n            throw new OperationError(error.toString() +\n            \"\\n\\nThis error could be caused by one of the following:\\n\" +\n            \" - An invalid Resolver URL\\n\");\n        }\n        const params = {name: input, type: requestType, cd: DNSSEC};\n\n        url.search = new URLSearchParams(params);\n\n        return fetch(url, {headers: {\"accept\": \"application/dns-json\"}}).then(response => {\n            return response.json();\n        }).then(data => {\n            if (justAnswer) {\n                return extractData(data.Answer);\n            }\n            return data;\n        }).catch(e => {\n            throw new OperationError(`Error making request to ${url}\\n${e.toString()}`);\n        });\n\n    }\n}\n\n/**\n * Construct an array of just data from a DNS Answer section\n *\n * @private\n * @param {JSON} data\n * @returns {JSON}\n */\nfunction extractData(data) {\n    if (typeof(data) == \"undefined\") {\n        return [];\n    } else {\n        const dataValues = [];\n        data.forEach(element => {","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/DNSOverHTTPS.mjs#L99-L135","documentation":"Thrown by DNS over HTTPS run() inside the fetch promise chain's .catch(), wrapping any network/fetch failure during the DoH request or its response.json() parse. The error includes the resolved URL and the stringified exception. Because the operation runs in a browser/worker context, this is where CORS aborts, DNS failures of the resolver itself, timeouts, and non-JSON responses surface.","triggerScenarios":"fetch() rejects (network down, resolver hostname unresolvable, CORS blocked, certificate error, mixed-content block on http page) OR response.json() rejects (resolver returned HTML/non-JSON, 4xx/5xx body that is not valid JSON). The .catch wraps both stages.","commonSituations":"Running CyberChef on an airgapped/offline network; a corporate proxy blocking the DoH endpoint; the resolver returning an error page (HTML) instead of application/dns-json; browser mixed-content policy blocking https fetch from an http origin; the chosen resolver URL being unreachable.","solutions":["Verify network connectivity to the resolver host (curl the URL with the accept header).","Switch to the other built-in resolver (Google vs Cloudflare) in case one is blocked.","Ensure CyberChef is served over https if the page is public, to avoid mixed-content blocking.","Confirm the custom resolver actually returns application/dns-json for the query; if it returns wireformat, it is the wrong endpoint.","Check for proxy/firewall rules blocking the DoH endpoint."],"exampleFix":"// before - resolver returns wireformat (RFC8484), not dns-json\nResolver: https://dns.example/dns-query (wireformat)\n\n// after - use a dns-json (RFC8484 GET-json) endpoint\nResolver: https://cloudflare-dns.com/dns-query","handlingStrategy":"retry","validationCode":"// cannot fully validate network reachability pre-call, but can sanity-check the URL\nfunction canAttemptFetch(resolver) {\n    try {\n        const u = new URL(resolver);\n        return (u.protocol === \"https:\" || u.protocol === \"http:\") && /^https:\\/\\/(dns\\.google\\.com|cloudflare-dns\\.com)/.test(u.origin);\n    } catch {\n        return false;\n    }\n}","typeGuard":"/** @returns {boolean} */\nfunction isKnownDohOrigin(resolver) {\n    try {\n        const u = new URL(String(resolver));\n        return [\"https://dns.google.com\", \"https://cloudflare-dns.com\"].includes(u.origin);\n    } catch {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    result = await dnsOverHttps.run(input, args);\n} catch (e) {\n    if (e instanceof OperationError && /Error making request/.test(e.message)) {\n        // fall back to the alternate resolver, then surface a network error to the user\n        args[0] = \"https://cloudflare-dns.com/dns-query\"; // alternate default\n        result = await dnsOverHttps.run(input, args);\n    } else throw e;\n}","preventionTips":["Ensure outbound network access to the DoH endpoint (no proxy/firewall block).","Serve CyberChef over https to avoid mixed-content fetch blocks.","Confirm the resolver returns application/dns-json (not wireformat) for GET requests.","Keep a fallback resolver (Google vs Cloudflare) in the recipe for resilience."],"tags":["network","dns","fetch","cors"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}