Skip to content
ClickJack Test

← Blog

“Refused to Display in a Frame”: What It Means and How to Fix It

Published November 2026 · messages taken from the Chromium source

These console errors mean the page inside your iframe told the browser not to show it there. The framed site sent X-Frame-Options or a CSP frame-ancestors rule that does not allow your page. Only the owner of the framed page can change it.

Chrome logs one of these messages in the DevTools Console:

Refused to display 'https://www.example.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

Refused to display 'https://www.example.com/' in a frame because it set 'X-Frame-Options' to 'deny'.

Framing 'https://www.example.com/' violates the following Content Security Policy directive: "frame-ancestors 'self'". The request has been blocked.

Chrome 141 and older word the CSP message differently:

Refused to frame 'https://www.example.com/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".

The address in the message is the framed page's origin, such as 'https://www.youtube.com/', not the full URL. The text in quotes after frame-ancestors is the site's actual rule. Inside the frame itself, Chrome shows “www.example.com refused to connect.” and the request fails with ERR_BLOCKED_BY_RESPONSE.

Firefox reports the X-Frame-Options case with its own wording:

The loading of “https://www.example.com/” in a frame is denied by “X-Frame-Options“ directive set to “SAMEORIGIN“.

What each message means

Each message names the rule that blocked the frame. The rule decides who may show the page in a frame.

Message ends withWho may frame the page
to 'sameorigin'.Only pages on the same origin as the framed page (same scheme, host and port). Every page above it must match, not only the direct parent. A page nested inside another site is blocked too.
to 'deny'.Nobody. Not even pages on the site's own origin.
"frame-ancestors …"Only the sources listed in the rule. 'none' means nobody, 'self' means the same origin. Your origin was not on the list.
with conflicting values (…). Falling back to 'deny'.Nobody. The response had two different X-Frame-Options values, such as DENY and SAMEORIGIN, so Chrome treats it as DENY.

Nothing in the embedding page changes the result. The check reads only the framed page's response headers and the origins of the pages above it. Iframe attributes such as sandbox or allow do not help. For the full value syntax, see the X-Frame-Options reference and the frame-ancestors reference.

An enforced frame-ancestors overrides X-Frame-Options

If a response has a Content-Security-Policy header with frame-ancestors, the browser ignores X-Frame-Options on that response. This only counts for an enforced policy. A Content-Security-Policy-Report-Only header does not switch X-Frame-Options off.

Two things follow from this:

  • If you see an X-Frame-Options message, the framed response had no enforced frame-ancestors.
  • If you own the framed page, adding frame-ancestors is enough to replace an old X-Frame-Options in current browsers. The details and edge cases are in X-Frame-Options vs CSP frame-ancestors.

Why ALLOW-FROM and meta tags do not help

X-Frame-Options: ALLOW-FROM does not work. The HTML standard says browsers must not implement it. A lone value the browser does not recognize is treated as if the header were missing, so the page can be framed by anyone. Chrome logs Invalid 'X-Frame-Options' header encountered … The header will be ignored. To allow one partner origin, use frame-ancestors.

Meta tags do not work. The CSP standard does not support frame-ancestors in a <meta http-equiv> tag, and an X-Frame-Options meta tag is ignored too. Both must be real HTTP response headers. This works in both directions: a meta tag cannot block framing, and it cannot allow framing that a header blocks.

Fix: you own the framed page

Send frame-ancestors with every origin that should be able to embed the page. Use exact origins with the scheme:

Content-Security-Policy: frame-ancestors 'self' https://app.example.com https://partner.example.org

Then clean up the old header:

  1. Remove X-Frame-Options: SAMEORIGIN or DENY from the framed page. Current browsers ignore it once frame-ancestors is there, but a browser that does not support frame-ancestors would still block your partner.
  2. If you saw the “conflicting values” message, the header is added in two places, for example by the app and by a proxy or CDN. Set it in one layer only.

Where to set the header on your stack: NGINX, Apache, Cloudflare, Next.js, WordPress and IIS. After you deploy, check the page with the iframe tester.

Only allow origins you trust. Every origin in the list can frame your page and could use it for clickjacking. If the page has logins or buttons that change data, keep the list short.

Fix: you do not own the framed page

You cannot remove another site's header. These options work:

  • Use the official embed URL. Many services offer a separate address built for iframes. It is usually under “Share” then “Embed”. Our refused-to-connect guides cover the options for Google Docs, Google Drive, Google Search and Microsoft sign-in.
  • Link out instead. Replace the iframe with a link that opens the page in a new tab. The framing rules do not apply to a page loaded as the main page of a tab.
  • Ask the owner. If you are a partner, ask them to add your origin to their frame-ancestors list.

The common case: a YouTube watch URL in an iframe

The most common source of the 'sameorigin' message is a YouTube link pasted into an iframe. YouTube watch pages send X-Frame-Options: SAMEORIGIN. The embed address for the same video does not (both checked on November 30, 2026). Change the URL:

<!-- Blocked: watch page -->
<iframe src="https://www.youtube.com/watch?v=VIDEO_ID"></iframe>

<!-- Works: embed URL -->
<iframe src="https://www.youtube.com/embed/VIDEO_ID"></iframe>

YouTube's Share → Embed button gives you the full iframe code. More detail is in YouTube refused to connect.

Check whether a URL can be embedded →

Check your headers

See whether a site sends X-Frame-Options or CSP frame-ancestors, and what browsers will do with them.