# What does 'Refused to display in a frame because it set 'X-Frame-Options' to 'sameorigin'' mean?

**Short answer:** The framed page tells browsers not to be embedded by other sites, via `X-Frame-Options` or CSP `frame-ancestors`. That's clickjacking protection working. If you own both sites, allow your exact parent origin with `frame-ancestors`. If you don't own the framed site, you can't override it, so link to it instead.

*Last updated 2026-11-25 · Reviewed by ProofForge*

## The exact error

```text
Refused to display 'https://app.example.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
Refused to frame 'https://app.example.com/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".
```

## Why it happens

- The site sends `X-Frame-Options: DENY` or `SAMEORIGIN`.
- The site's CSP has `frame-ancestors 'none'` or `'self'`.
- Third-party login and payment pages always refuse framing.

## How to fix it

1. On the site being framed, replace X-Frame-Options with an explicit allowlist:
2. Keep `'none'` on pages that should never be framed (login, settings, checkout).

```http
Content-Security-Policy: frame-ancestors 'self' https://dashboard.example.com
```

## Check it's fixed

The embed works on your allowed origin, and the page still refuses to load inside an iframe on any other site.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## FAQ

### Can I remove X-Frame-Options to make it work?
Only if you replace it with `frame-ancestors` listing specific origins. Removing both lets any site overlay your app and trick users into clicks.

### Which wins if both are set?
Browsers that support `frame-ancestors` use it and ignore X-Frame-Options.

### Can frame-ancestors go in a meta tag?
No, it's ignored in `<meta>`. It must be an HTTP response header.

## Sources

- [MDN: X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options)
- [MDN: CSP frame-ancestors](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors)

## Related

- [Fix: missing security headers](/fix/missing-security-headers)
- [Security headers checker](/tools/security-headers-checker)
- [Fix 'Refused to load the script' (CSP violation)](/errors/refused-to-load-script-csp)
- [All errors](/errors)
