CSP violation JavaScript Origin: On your device Last updated 9 Oct 2026

Refused to load the script because it violates the following Content Security Policy directive

The page’s Content-Security-Policy doesn’t allow that script, style, image or connection source.

Exact message you may see violates the following Content Security Policy directiveRefused to load the scriptRefused to connect toRefused to apply inline style
Seen on: JavaScript

Meaning

CSP headers whitelist sources. New third-party scripts (analytics, ads, fonts), inline scripts or eval are blocked until added to the policy.

Common causes

  • Third-party domain not in script-src/connect-src
  • Inline script without nonce/hash
  • eval/new Function blocked by missing unsafe-eval
  • Images/fonts from unlisted domains

⚡ Quick fix

  1. Add the domain to the right directive
  2. Use nonces/hashes for inline scripts
  3. Test with Content-Security-Policy-Report-Only first

Detailed fix by platform

Nginx

  1. add_header Content-Security-Policy "script-src 'self' https://www.googletagmanager.com" always;

How to diagnose

  1. Directive — Which directive is violated?
  2. Source — Which URL was blocked?

🔧 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):

$ is not defined — Console: Uncaught ReferenceError: $ is not defined (jQuery not loaded or loaded after your code) (Browser)$ is not defined100 — HTTP 100 Continue (HTTP)100103 — HTTP 103 Early Hints (HTTP)1031040 — Cloudflare Error 1040 / 1041: Invalid request header modification (Cloudflare)1040411 — HTTP 411 Length Required (HTTP)411416 — HTTP 416 Range Not Satisfiable (HTTP)416428 — HTTP 428 Precondition Required (HTTP)428blocked a frame — SecurityError: Blocked a frame with origin "x" from accessing a cross-origin frame. (JavaScript)blocked a frameCSP viola…

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.