Skip to content
ClickJack Test

← Refused to connect

script.google.com refused to connect

Why Google Apps Script will not load in a frame, and what to do. Headers checked 2026-11-30.

An Apps Script web app loads in frames on other sites only when the script allows it. Add .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL) to the HTML output, then update the deployment to a new version. If you only use a script or add-on, you are most likely signed in to more than one Google account.

What the site sends

Framing header
X-Frame-Options in the DEFAULT mode, none with XFrameOptionsMode.ALLOWALL (per Google's reference)
Checked URL
https://script.google.com/macros/s/DEPLOYMENT_ID/exec
Checked on
2026-11-30

Why it happens

If a script does not set a mode, Apps Script uses the DEFAULT mode, which sets the X-Frame-Options header. The ALLOWALL mode sets no header, so any site can frame the page.

A second cause has nothing to do with that header. A web app that needs sign-in can send a frame with no usable Google session to the sign-in page, which never loads in a frame.

Fix it if you are embedding Google Apps Script

Allow framing in doGet

Set the mode on the output you return. A versioned deployment keeps running the code it was created with, so open Deploy, then Manage deployments, edit the deployment, and choose the new version.

function doGet() {
  return HtmlService.createHtmlOutputFromFile('Index')
    .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

Embed the /exec URL, not /dev

The test URL ends in /dev and only works for people with edit access to the script. Embed the deployment URL that ends in /exec.

Remove the sign-in step for public pages

For a page everyone may see, deploy the web app to execute as you and give access to anyone. The script then runs as you, so visitors need no Google session.

If you only see the error

Being signed in to more than one Google account is a common cause. Google may not know which account the frame should use, and can fall back to your default account. If that account cannot open the file, the frame cannot show it. Open the page in a private window and sign in with only the account that has access. To fix it for good, sign out of every Google account, then sign in first with the one you need: in many cases Google treats the first account you sign in with as the default.

FAQ

I added ALLOWALL and it still refuses to connect. Why?

You are most likely still serving the old version. Edit the deployment to use a new version, then reload. If the app needs sign-in, also test in a private window with one account.

Is ALLOWALL safe?

It lets any site show your web app in a frame, so Google says you must add your own clickjacking protection. Use it only for pages meant to be embedded, and keep actions that change data behind a confirmation step.

Check your headers

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