Service worker registration failed Browser Origin: On your device Last updated 15 Oct 2026

Console: Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script

The browser could not fetch, parse or install the service worker script, or the page is not allowed to register one (HTTPS and scope rules).

Exact message you may see Failed to register a ServiceWorkerA bad HTTP response code (404) was received when fetching the scriptThe script has an unsupported MIME typeSecurityError: Failed to register a ServiceWorkerThe path of the provided scope is not under the max scope allowed
Seen on: Chrome Firefox JavaScript Nginx

Meaning

Service workers need a secure context (HTTPS or localhost), a script reachable at its URL with a JavaScript MIME type, and a scope no wider than the script's folder unless Service-Worker-Allowed is sent. The console message names the exact reason: 404, MIME type, scope or SSL certificate error.

Common causes

  • Wrong URL for sw.js (404 or SPA fallback returning HTML)
  • Not served over HTTPS (except localhost)
  • Script served with a non-JavaScript MIME type
  • Scope wider than the script location
  • Syntax error in the worker or certificate error

⚡ Quick fix

  1. Open the script URL directly — it must return JavaScript
  2. Use HTTPS (or localhost for development)
  3. Place sw.js at the site root or send Service-Worker-Allowed

Detailed fix by platform

JavaScript

  1. navigator.serviceWorker.register('/sw.js', { scope: '/' }).catch(console.error); — read the rejected error message
  2. DevTools → Application → Service Workers shows status and errors

Nginx

  1. Serve with the right header for scope: location = /static/sw.js { add_header Service-Worker-Allowed "/"; }

How to diagnose

  1. URL — Does /sw.js load as JavaScript?
  2. Context — HTTPS or localhost?
  3. Scope — Within the script's folder?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

404 — HTTP 404 Not Found (HTTP)404Aw, Snap! — Chrome: Aw, Snap! Something went wrong while displaying this webpage. Error code: STATUS_ACCESS_VIOLATION / SIGILL / Out of Memory (Browser)Aw, Snap!captive portal — Browser: This network requires you to sign in — captive portal (hotel, airport, café Wi-Fi) blocking HTTPS sites (Browser)captive portalMIME type not executable — Refused to execute script from 'x' because its MIME type ('text/html') is not executable (JavaScript)MIME type not executa…module MIME type — Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html" (JavaScript)module MIME typeThe canvas has been tainted by cross-origin data — Console: SecurityError: Failed to execute 'toDataURL' / 'getImageData' on 'HTMLCanvasElement': Tainted canvases may not be exported (Browser)The canvas has been t…Unchecked runtime.lastError — Console: Unchecked runtime.lastError: The message port closed before a response was received (extension message) (Browser)Unchecked runtime.las…VersionError — Console: VersionError: The requested version (1) is less than the existing version (2) — IndexedDB open() failed (Browser)VersionErrorService w…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.