Home / Fix guides / Website security

How to fix a missing X-Frame-Options header

The X-Frame-Options header tells browsers whether other websites may show your pages inside a frame. To fix it, make your server send X-Frame-Options: SAMEORIGIN (or DENY) with every page, then check that nothing you embed on purpose has broken.

A security scan may report "Missing X-Frame-Options header" or "clickjacking protection not enabled". It sounds alarming, but the fix is usually one line of server configuration. This page explains what the warning means, how to check your own site for free, and how to add the header on the most common setups.

What the problem is and what you see

Visitors see nothing. The header is an instruction sent in the background with each page, and when it is missing, browsers allow any other website to load your page inside a frame (an iframe).

That opens the door to clickjacking. An attacker builds a page with a harmless looking button, such as "Play video" or "Claim your prize". Your page is loaded invisibly on top of it. The visitor thinks they are clicking the decoy, but they are really clicking a button on your site, for example "Confirm" or "Delete", and if they are logged in the action goes through as them.

Why it matters

  • Security: the risk is highest on pages where a logged in person can do something: admin areas, account pages, checkout, settings. A simple brochure page with no login carries much less risk.
  • Trust and sales: security scanners, insurers and larger customers often run the same checks. A missing header can show up in their report about your business.
  • Search: it is not a ranking factor. Google does not rank you lower for it. The reason to fix it is protection, not SEO.

It is rarely an emergency, but it is cheap to fix, so it is worth doing.

How to check if your site has it

All of these are free.

  1. Command line: run the command below, replacing the address with your own. Look for a line starting with x-frame-options.
  2. Browser: open your site, press F12 to open developer tools, go to the Network tab, reload, click the first request (your page) and read the Response Headers.
  3. Online header checker: free tools such as securityheaders.com list the headers your site sends and show which are missing.
curl -I https://example.com

Check more than the home page. Login, checkout and account pages sometimes send different headers from the rest of the site.

This problem is one of the things the OpenVAS security scan in week 2 of SiteMonday looks for. Scans only run after the owner proves they own the site.

Which value to use

ValueWhat it does
DENYNo site may frame your pages, not even your own
SAMEORIGINOnly your own site may frame your pages
ALLOW-FROMObsolete, modern browsers ignore it

For most small business sites, SAMEORIGIN is the safe choice. It blocks other websites but will not break anything your own site does. Use DENY if you are sure nothing on your site ever frames its own pages.

The modern replacement is the frame-ancestors directive of the Content-Security-Policy header, for example Content-Security-Policy: frame-ancestors 'self'. Browsers that support it use it instead of X-Frame-Options. Many sites send both, because the old header still helps with older browsers and many scanners still look for it. If you need to allow one specific partner site to frame you, frame-ancestors is the way to do it.

How to fix it in general

The header must be sent by the web server as part of the HTTP response. Putting it in a <meta> tag in your page does not work, browsers ignore it there.

On Nginx, add this line inside the server block (or http block), then reload Nginx. The always part makes sure it is also sent on error pages. There is a step by step Nginx guide.

add_header X-Frame-Options "SAMEORIGIN" always;

On Apache, add this to your site configuration or .htaccess file. It needs the mod_headers module, which is enabled on most hosts. See the Apache guide.

Header always set X-Frame-Options "SAMEORIGIN"

Common platforms

The exact menu names depend on your version, theme and host, so treat these as pointers.

  • WordPress: WordPress itself only sends the header on login and admin screens, not on public pages. The cleanest fix is the server configuration above. If you cannot edit the server, a security headers plugin from the official plugin directory can add it. Read the WordPress guide first. Your host's support team can also add it for you.
  • Cloudflare: in the dashboard, look under Rules for Transform Rules, then Modify Response Header, and add a rule that sets X-Frame-Options to SAMEORIGIN on all requests.
  • IIS: in web.config, add the header inside system.webServer, httpProtocol, customHeaders. The IIS Manager has the same setting under HTTP Response Headers.
  • Netlify: add a _headers file in your publish folder, or a [[headers]] block in netlify.toml.
  • Vercel: add a headers entry in vercel.json for the source /(.*).
  • Shared hosting with a control panel: you can often use the .htaccess method above. If not, ask your host.

Check that nothing breaks

Before and after the change, look at any page where you embed something from another source, or where another site embeds you. Typical examples are booking widgets, payment pages, page builder previews and customer portals. If a widget shows a blank box after the change, it was probably being framed across sites. In that case, use frame-ancestors to allow only the specific address involved, instead of removing the protection.

Also make sure the header is not sent twice with different values, for example once by your server and once by a plugin or CDN. Conflicting copies can be ignored by browsers or cause confusing behaviour. Pick one place to set it.

How to confirm the fix worked

  1. Clear any cache (your site cache plugin, your CDN cache) so you are not seeing an old response.
  2. Run curl -I on your home page and on a login or checkout page. You should see one x-frame-options line with the value you chose.
  3. Load your site in the browser and click through the main pages and forms.
  4. Run an online header checker again, or wait for the next scan, to see that the finding is gone.

How to stop it coming back

  • Set the header in one central place (server config, CDN rule or hosting settings), not page by page.
  • Keep a note of where it is set, so whoever moves the site or changes host knows to copy it across.
  • After a migration, server rebuild or CDN change, run curl -I again. Headers set in the old setup are the first thing to go missing.
  • Re-scan regularly. Because SiteMonday runs a new service every Monday for 52 weeks, a fresh security scan can show whether a header disappeared after a change. SiteMonday finds and explains the problem, and the fix itself is up to you or your developer.

Step by step for your platform

Questions

Is a missing X-Frame-Options header a serious problem?

It is usually low to medium risk. It matters most on pages where a logged in user can take actions, and it is a quick fix, so it is worth doing.

Should I use DENY or SAMEORIGIN?

SAMEORIGIN is the safe default for most small business sites because it blocks other websites but allows your own pages to frame each other. Use DENY only if nothing on your site frames its own pages.

Is X-Frame-Options replaced by Content-Security-Policy?

Partly. The `frame-ancestors` directive is the modern standard and takes priority in browsers that support it. Many sites send both, because scanners and older browsers still use X-Frame-Options.

Can I add X-Frame-Options with a meta tag?

No. Browsers only honour it as an HTTP response header, so it has to be set by your server, CDN or hosting settings.

Will adding the header break my embedded videos or booking widgets?

Not if those are content you embed from others, because the header controls who can frame your pages, not what you frame. It can break things if another site is meant to embed your pages, in which case allow that specific site with `frame-ancestors`.

Does this affect my Google rankings?

No, it is not a ranking factor. The reason to fix it is to protect your visitors and customers.

Related problems