Fix guides · Firefox, Next.js, React, Vite, Cursor, Vercel, Netlify ·

Fix Firefox "NetworkError when attempting to fetch resource"

TypeError: NetworkError when attempting to fetch resource.

Firefox throws "TypeError: NetworkError when attempting to fetch resource." when the Fetch API fails at the network level — the request never reaches the server or is blocked before a response is received. This is Firefox's specific wording; Chromium throws "TypeError: Failed to fetch" and WebKit throws "TypeError: Load failed". Common causes: mixed content (HTTPS page fetching HTTP), CORS preflight failure, browser extensions blocking the request, network-level blocks (firewall, VPN, antivirus), or the request being aborted (e.g., page navigation during fetch). The fix depends on the root cause — check DevTools Network tab for the blocked request.

Free · 3 a day · no signup

Common causes – and how to tell which one you have

1. Mixed content (HTTPS page → HTTP API)

How to tell: The page loads over HTTPS but the fetch URL is an insecure HTTP endpoint. Mixed content is blocked and shown as a warning in the browser console and as a blocked/insecure indicator in the address bar.

Fix: Change the API endpoint to HTTPS. In development, use a local HTTPS proxy (e.g., mkcert + ngrok) or configure the dev server to serve HTTPS.

2. CORS preflight failure

How to tell: The request is an OPTIONS preflight that returns no CORS headers, or the actual request lacks Access-Control-Allow-Origin. The Network tab shows the OPTIONS request failing or the response missing the header.

Fix: Configure the API server to respond to OPTIONS with Access-Control-Allow-Origin: your-origin (or * for public APIs), Access-Control-Allow-Methods, and Access-Control-Allow-Headers. For Next.js API routes, use the cors package or middleware.

3. Browser extension blocking the request

How to tell: The request works after disabling extensions or in a Private Window. In the Network tab the request shows as blocked or has no response at all, with no matching entry in the server logs.

Fix: Either adjust the extension settings to allow the domain, or ensure the request doesn't trigger blocking (e.g., avoid tracker-like patterns, use first-party domains). For production, you cannot control users' extensions — design graceful degradation.

4. Request aborted by navigation

How to tell: The Network tab shows the request as "Canceled" (gray). This happens when a fetch is triggered on a button click that also navigates, or when the page navigates away before the fetch completes. Note: an explicit AbortController.abort() rejects the fetch with a DOMException named AbortError, not this NetworkError.

Fix: Prevent the default navigation until the fetch completes (await the fetch inside an async handler, then navigate). If you are using AbortController, abort only when the user intentionally cancels the request.

5. Service worker intercepting and failing

How to tell: The request works after unregistering the service worker in about:debugging#/runtime/this-firefox (Firefox) or via the Application/Service Workers panel (Chrome). The SW may be returning a failed response.

Fix: Fix the service worker's fetch handler to properly handle the request, or exclude the API path by returning without calling event.respondWith for that path: const path = new URL(event.request.url).pathname; if (path.startsWith('/api/')) { return; } event.respondWith(fetch(event.request));

How to fix it

  1. Open Firefox DevTools (F12) → Network tab. Reproduce the error. Find the failing request — it will show "NetworkError" or have no status code.
  2. Check the request URL: if it uses plain HTTP on an HTTPS page, this is a mixed-content block. Fix by using HTTPS for the API endpoint.
  3. Check the response headers (if any): if CORS headers are missing (Access-Control-Allow-Origin), the preflight failed. Ensure the server responds to OPTIONS with the correct CORS headers for your origin.
  4. Disable browser extensions (especially ad blockers, privacy tools, VPN extensions) and retry. Extensions like uBlock Origin, Privacy Badger, or Firefox's built-in tracking protection can block fetch requests.
  5. Check Firefox's Network panel for "Blocked" or "Canceled" status. A canceled request usually means the page navigated away before the fetch completed. Note that an explicit AbortController.abort() instead rejects with a DOMException named AbortError, not this NetworkError.
  6. Test in a Firefox Private Window (Ctrl+Shift+P) to rule out extensions and cache. If it works in Private Window, an extension or cached redirect is the cause.
  7. If the request targets a server you run locally, confirm the server is actually running and reachable (curl the URL from a terminal). A NetworkError here usually means the process is down or on a different port, not a browser privacy block.
  8. If the page uses a service worker: open about:debugging#/runtime/this-firefox in Firefox, find your site's service worker and click Unregister, then reload and retry the fetch.

Copy-paste fix prompt for your AI coding tool

Paste this into Cursor, Claude Code, Lovable or Bolt:

My app throws TypeError: NetworkError when attempting to fetch resource. in Firefox (works in Chrome). This is a network-level block, not an HTTP error. Check in order: 1) Mixed content — HTTPS page fetching HTTP endpoint. 2) CORS — missing Access-Control-Allow-Origin on the API response or OPTIONS preflight. 3) Browser extensions — disable ad blockers/privacy tools and test in Private Window. 4) Request aborted — check for page navigation during fetch (a fetch on a navigating button or link). 5) Service worker interference. Fix the root cause and verify the fetch succeeds in Firefox DevTools Network tab with a 200 response.
Your error looks a bit different? Paste your exact error and get a diagnosis tailored to your code — free.

Official documentation

Related errors

Get fixes like this every week