CSP HTTP Origin: Network OSI layer 7 · Application Last updated 18 Nov 2026

Refused to execute inline script because it violates the Content Security Policy

The page's Content-Security-Policy forbids inline scripts, so the browser blocked yours.

Exact message you may see Refused to execute inline script because it violates the following Content Security Policy directiveRefused to execute inline event handler because it violates the following Content Security Policy directiveContent-Security-Policy: The page's settings blocked an inline script (script-src-elem)'unsafe-inline' is ignoredviolates CSP directive script-src
Seen on: HTTP Browser JavaScript

Meaning

CSP without 'unsafe-inline' blocks inline <script> and onclick= handlers. Move scripts into files, or allow specific inline blocks with a nonce (script-src 'nonce-...') or hash. Check the console for the exact directive and the report-only mode to test.

Common causes

  • script-src 'self' without nonce/hash
  • Inline script or event-handler attribute
  • Third-party snippet injecting inline code
  • CSP header added by a proxy/plugin
  • Missing nonce in the rendered tag

⚡ Quick fix

  1. Move inline code into external files
  2. Add a per-request nonce and put it on trusted tags
  3. Use Content-Security-Policy-Report-Only to test changes

Detailed fix by platform

HTTP

  1. Content-Security-Policy: script-src 'self' 'nonce-r4nd0m'

How to diagnose

  1. Directive — script-src?
  2. Nonce — On the tag?
  3. Inline — Needed?

🔧 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: Network. Errors that are often confused with or caused by this one (click to open):

102 — HTTP 102 Processing (HTTP)1021101 — Cloudflare Error 1101: Worker threw exception (Cloudflare)1101201 — HTTP 201 Created (HTTP)201COOP/COEP — SharedArrayBuffer is not defined: cross-origin isolation headers missing (COOP/COEP) (HTTP)COOP/COEPCSP violation — Refused to load the script because it violates the following Content Security Policy directive (JavaScript)CSP violationfetch — fetch() doesn't throw on 404/500 — response.ok must be checked (HTTP)fetchMIME type not executable — Refused to execute script from 'x' because its MIME type ('text/html') is not executable (JavaScript)MIME type not executa…Refused to display in a frame — Console: Refused to display 'https://…' in a frame because it set 'X-Frame-Options' to 'deny' / 'sameorigin' (Browser)Refused to display in…CSP

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.