HTTP, TLS & Web Performance

Mixed Content Warnings and How to Fix Them

Find out why secure pages complain about insecure resources, how browsers handle each type, and how to locate and fix every offender on your site.

Key takeaways

  • Mixed content is an insecure subresource on a secure page, and it weakens the protection HTTPS is meant to give.
  • Modern browsers block insecure scripts, stylesheets and frames, and try to upgrade images, audio and video to HTTPS.
  • The browser's developer console names each offending URL, which is the fastest way to start.
  • Fix addresses at the source: templates, databases, stylesheets, scripts and third-party embeds.
  • A Content Security Policy can upgrade stragglers and report them while you clean up.

Mixed content happens when a page loaded over HTTPS pulls some of its parts, such as images, scripts or stylesheets, over plain HTTP. Browsers either upgrade those requests to HTTPS or block them, so you may see missing pictures, broken layouts, dead buttons or console warnings.

The fix is to make every resource load over HTTPS. The harder part is finding all the places an old http:// address hides. This guide covers both.

Why it matters

A secure page is only as trustworthy as what it runs. If a script arrives over HTTP, anyone able to alter network traffic can replace it with their own code. That code runs with full access to the page: it can read what you type, change what you see and send data elsewhere.

An insecure image is less dangerous but not harmless. Someone on the path could swap it for a misleading one, such as an altered payment instruction, and can see exactly which file you requested. What HTTPS guarantees only applies to traffic that actually uses it.

Two broad categories

The W3C Mixed Content specification and browser behavior divide resources by how much damage tampering could do.

How browsers treat insecure resources on secure pages
Blocked outright Scripts and stylesheets Frames Fetch and XMLHttpRequest calls Fonts and most other loads Upgraded to HTTPS Ordinary images Audio files Video files Blocked or broken if HTTPS fails VS Blocked outright Scripts and stylesheets Frames Fetch and XMLHttpRequest calls Fonts and most other loads Upgraded to HTTPS Ordinary images Audio files Video files Blocked or broken if HTTPS fails

The first group is often called blockable or active content, the second upgradeable or passive content. With upgrading, the browser rewrites the request to HTTPS on its own. If the server can deliver the file securely, you notice nothing apart from a console note. If it can't, the resource fails to load. Exact handling varies between browsers and versions.

Two related cases are worth knowing. A form on a secure page that submits to an HTTP address sends what the visitor typed in the clear, and browsers warn about it. And an ordinary link to an HTTP page isn't mixed content, because following it is a navigation, though upgrading those links is still a good idea.

What you see

Symptoms depend on what was blocked:

  • Missing images or silent video players.
  • A page with no styling at all.
  • Menus, carts or maps that do nothing.
  • A "not secure" indicator or an altered address bar icon.
  • Console messages that mention "Mixed Content" and a URL.

Visitors can't fix this properly. Some browsers let you allow insecure content for a single site, but doing so removes a real protection. Reporting the problem to the owner is the better move.

Finding every offender

Open developer tools (F12 on many Windows and Linux browsers, Option+Command+I in several macOS browsers), select the Console and reload the page. Each insecure request is listed. The Network panel shows blocked entries too. A beginner's tour of developer tools helps if these are new.

One page isn't the whole site, so widen the search:

  1. Check each template type: home, article, product, checkout, search results and error pages.
  2. Search your source code for the string http://.
  3. Search the database, where content editors may have pasted absolute addresses.
  4. Look inside CSS for url(http://...) and in JavaScript for built-up addresses.
  5. Review third-party tags, embeds and widgets.

To search a code folder on Linux or macOS:

grep -rnE "(src|href|action)=[\"']http://|url\([\"']?http://" ./site

In Windows PowerShell:

Get-ChildItem .\site -Recurse -File | Select-String -Pattern 'http://'

Expect harmless matches, such as XML namespace identifiers inside SVG files. Those are names, not requests, and should be left alone.

Fixing the addresses

What to do with each insecure URL
Is it a file on your own site? YES Use a root-relative path such as /images/logo.png. 1 NO Does the other host serve the same file over HTTPS? YES Change the address to https and test it. 2 NO May you legally copy and host the file yourself? YES Move it to your server or CDN. 3 NO Does another provider offer an equivalent over HTTPS? YES Switch providers and update the embed code. 4 NO Remove it An insecure-only resource doesn't belong on a secure page. Is it a file on your own site? 1 IF YES Use a root-relative path such as /images/logo.png. NO Does the other host serve the same file over HTTPS? 2 IF YES Change the address to https and test it. NO May you legally copy and host the file yourself? 3 IF YES Move it to your server or CDN. NO Does another provider offer an equivalent over HTTPS? 4 IF YES Switch providers and update the embed code. NO Remove it An insecure-only resource doesn't belong on a secure page.

Your own files are best referenced with root-relative paths, which inherit the page's scheme and host. The older trick of protocol-relative addresses (//host/file) still works but offers no advantage over writing https://.

Database content often needs a bulk replacement of http://yourdomain with https://yourdomain. Back up first, and use a tool that understands your platform's data format. Some content systems store serialized values where a plain text replacement corrupts settings. Check your system's site address setting too, since it frequently generates the bad links.

Applications behind a proxy may think requests are HTTP because TLS ends at the proxy, and then build http:// URLs. Configure the proxy to pass the original scheme, commonly in X-Forwarded-Proto, and configure the application to trust it only from that proxy. Reverse proxies explained covers this arrangement.

Third-party embeds and feeds

Code you copied from somewhere else years ago is a frequent source of trouble. Old video embeds, counters, maps, badges and advertising snippets often carry http:// addresses, and some point to services that have since changed hosts or closed.

Get a current snippet from the provider instead of editing the old one by hand, because paths and parameters may have changed along with the scheme. Check what the snippet loads once it runs: a secure script can still request insecure files of its own, which only shows up in the console after the widget starts. If a vendor can't deliver everything over HTTPS, drop it.

Images that arrive from outside feeds or user submissions need a policy too. You can reject insecure addresses at the point of entry, rewrite them after confirming the secure version works, or copy permitted files into your own storage. Avoid building an open proxy that fetches any address a user supplies, since attackers can abuse it to reach systems your server can see. Restrict allowed hosts, file types and sizes if you fetch remote files at all.

Check the result

When you think you're finished, verify with fresh eyes:

  1. Open the main templates in a private window with the console visible and cache disabled.
  2. Exercise the interactive parts: search, forms, carts, galleries and pop-ups.
  3. Scroll to the bottom of long pages so deferred content loads.
  4. Test on a phone, which may receive different images or scripts.
  5. Watch violation reports for a few weeks, since rarely visited pages surface slowly.

Remember email templates and downloadable documents that link to your resources. They aren't mixed content in a browser sense, but updating them saves a redirect and removes an insecure first step for readers. Update the address in your sitemap, canonical tags and social preview tags at the same time, so machines that read your pages get the secure version directly.

Using Content Security Policy

A response header can tell the browser to upgrade all insecure subresource requests before making them:

Content-Security-Policy: upgrade-insecure-requests

It's useful for large sites with years of old content. It doesn't help when the other server has no HTTPS: the upgraded request simply fails. It also only changes how browsers load the page, leaving the stored addresses wrong for feeds, emails and other consumers. Treat it as a safety net while you correct the source.

To discover problems from real visitors without changing behavior, use the report-only header:

Content-Security-Policy-Report-Only: default-src https: 'unsafe-inline' 'unsafe-eval' data: blob:; report-uri /csp-report

This policy is deliberately loose and aimed at flagging non-HTTPS loads. report-uri is older but widely understood; a newer report-to mechanism also exists. You need an endpoint that accepts the reports, and you should expect some noise from visitors' browser extensions.

A cleanup plan

Clearing mixed content from a site
1 Inventory Crawl pages and collect console and report data 2 Fix sources Templates, styles, scripts and settings 3 Clean content Update stored URLs after a backup 4 Add safety net Send upgrade-insecure-requests 5 Prevent return Check new content automatically Inventory Crawl pages and collect console and report data 1 Fix sources Templates, styles, scripts and settings 2 Clean content Update stored URLs after a backup 3 Add safety net Send upgrade-insecure-requests 4 Prevent return Check new content automatically 5

To stop it coming back, add a check to your publishing or build process that rejects new http:// resource addresses, and tell editors to paste secure links. Once the site is clean, consider HSTS to keep navigation on HTTPS. Note that HSTS upgrades requests to hosts that have a policy, so it doesn't solve mixed content pointing at other people's domains.

Special cases

WebSockets follow the same rule: a secure page should connect with wss://, and an insecure ws:// connection is generally refused. See keeping connections open.

Local devices and development servers raise their own questions, because browsers treat localhost as potentially trustworthy but are stricter about pages reaching devices on a private network. If your web app talks to hardware on a LAN, expect to need HTTPS on the device or a different design, and check current browser documentation.

Redirects can sneak insecurity back in. An HTTPS image address that redirects to HTTP is still mixed content. Follow the chain with:

curl -sIL https://example.com/image.jpg | grep -iE "^(HTTP|location)"

Common questions

Why did this start after I added a certificate?

The insecure addresses were always there. They only count as mixed once the page itself is secure.

The console is clean but the browser still says not secure. Why?

Check the certificate itself, any form targets and content loaded after user actions, such as pop-up windows or infinite scrolling. Reload with the cache cleared, since an old response may be in use.

Broken images, styles or scripts can hurt how a page renders for visitors and crawlers alike. Fixing it is worthwhile for users first, and that usually serves search as well.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in HTTP, TLS & Web Performance →

Latest news on this topic