Refused to connect
Why a site will not load in an iframe, how to find the header that blocks it, and what fixes it.
When a frame shows “host refused to connect”, that site told the browser not to show it inside a frame on another site. It does this with the X-Frame-Options header or the CSP frame-ancestors directive. Only the owner of that site can change it.
Two different errors use these words
Inside a frame. Chrome shows “host refused to connect.” in the frame, and the error code is ERR_BLOCKED_BY_RESPONSE. Edge and other browsers built on Chromium use the same error code, though their wording can differ. The cause is a framing header on the response. This page is about this error.
Chrome names the host of the response it blocked. If the site redirects the frame, for example to a sign-in page, the error names the last host, not the one in your src. That is why an embedded Google Doc can report accounts.google.com.
On a full page. “This site can’t be reached” with “host refused to connect.” and the code ERR_CONNECTION_REFUSED is a network error. Nothing accepted the connection at that address and port. With a local address such as localhost:3000, the usual cause is that your dev server is not running, crashed, or listens on another port. Start it again and use the port it prints. For a public site, check your connection, a proxy or VPN, and your firewall. No header is involved, so the rest of this page does not apply.
Find the header that blocks the frame
Console. Open DevTools (F12) on the page with the frame. When X-Frame-Options blocks it, Chrome logs a line like this:
Refused to display 'https://www.youtube.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.When CSP blocks it, the console message names the frame-ancestors directive instead.
Network panel. Reload with the Network panel open, select the request for the framed page (after a redirect, the last one), and read its Response Headers. Look for X-Frame-Options and for frame-ancestors inside Content-Security-Policy.
This site. Paste the URL into the iframe tester. It shows each framing header and what browsers do with it. From a terminal, curl -sI https://example.com/ prints the headers too.
What Firefox and Safari show
Firefox shows “Firefox Can’t Open This Page” in the frame, with: “To protect your security, host will not allow Firefox to display the page if another site has embedded it. To see this page, you need to open it in a new window.”
Safari shows no message. The frame stays empty. The Web Inspector console logs “Refused to display … in a frame because it set ‘X-Frame-Options’ to …”.
Fix it if you own the framed site
Allow the sites that may embed you with CSP frame-ancestors. List your own origin and each embedding origin. Do not use * unless every site may frame you.
Content-Security-Policy: frame-ancestors 'self' https://partner.example.comBrowsers that support frame-ancestors ignore X-Frame-Options when an enforced policy has it, but a leftover X-Frame-Options: DENY or SAMEORIGIN still blocks older browsers. Remove it, or keep it only on pages no one should embed. Read the frame-ancestors reference, then follow the guide for your server in the setup guides (NGINX, Apache, Cloudflare, IIS, Next.js, WordPress).
Allowing framing removes your clickjacking protection for those origins, so allow only sites you trust.
If you do not own the framed site
- Use the official embed URL. Many sites serve a separate URL for other sites: YouTube’s
/embed/player, Google’s Publish to web, a post’s embed code. The pages below list them for popular sites. - Link out. Open the page in a new tab with
target="_blank". - Ask the owner to add your origin to their
frame-ancestorslist.
What does not work
- Meta tags. Browsers ignore
X-Frame-Optionsandframe-ancestorsin a<meta>tag, and the header comes from the framed site anyway, not from your page. - Iframe attributes.
sandbox,allow,referrerpolicyand the rest change what the framed page may do. None of them overrides the framed site’s headers. - Browser extensions that strip headers. They change the result only in the browser of the person who installed them. Your visitors still see the error.
- Clearing cache or cookies. The header is part of the site’s normal response. Cookies only matter when the site sends the frame to a sign-in page, as Google and Microsoft do.
Sites that often refuse to connect
- www.youtube.com refused to connectYouTube: X-Frame-Options: SAMEORIGIN
- docs.google.com refused to connectGoogle Docs: Redirects a signed-out request to Google sign-in (accounts.google.com), which sends X-Frame-Options: DENY
- drive.google.com refused to connectGoogle Drive: Redirects a signed-out request to Google sign-in (accounts.google.com), which sends X-Frame-Options: DENY
- login.microsoftonline.com refused to connectMicrosoft sign-in: X-Frame-Options: DENY
- www.google.com refused to connectGoogle Search: X-Frame-Options: SAMEORIGIN
- script.google.com refused to connectGoogle Apps Script: X-Frame-Options in the DEFAULT mode, none with XFrameOptionsMode.ALLOWALL (per Google's reference)
- sites.google.com refused to connectGoogle Sites: X-Frame-Options: DENY and Content-Security-Policy: frame-ancestors (one Google admin origin only)
- accounts.google.com refused to connectGoogle sign-in: X-Frame-Options: DENY
- mail.google.com refused to connectGmail: X-Frame-Options: SAMEORIGIN and Content-Security-Policy: frame-ancestors 'self'
- analytics.google.com refused to connectGoogle Analytics: X-Frame-Options: DENY
- www.linkedin.com refused to connectLinkedIn: X-Frame-Options: SAMEORIGIN and Content-Security-Policy: frame-ancestors 'self' (plus LinkedIn's own hosts)
- www.canva.com refused to connectCanva: X-Frame-Options: SAMEORIGIN
- www.facebook.com refused to connectFacebook: X-Frame-Options: DENY
Headers checked 2026-11-30.