What the message looks like
Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure script 'http://example.com/js/app.js'. This request has been blocked; the content must be served over HTTPS.Common causes
- Hard-coded
http://URLs in templates, CSS, JavaScript or in the content stored in the database. - The site moved to HTTPS but the CMS still has
http://insiteurl,homeor in old posts. - Behind a reverse proxy the application does not know the request was HTTPS and generates
http://links (missingX-Forwarded-Proto). - A third-party script, font or widget is loaded over HTTP.
- A redirect inside the application sends an API or asset request to an
http://address.
Check
- List http:// resources in the delivered HTML
curl -s https://example.com/ | grep -oE '(src|href|action)="http://[^"]+"' | sort -u | head -n 20 - Is a policy that upgrades requests already set?
curl -sI https://example.com/ | grep -i 'content-security-policy' - Does the proxy pass the scheme to the app?
nginx -T 2>/dev/null | grep -n 'X-Forwarded-Proto' - The exact blocked URLs
curl -s https://example.com/assets/app.css | grep -oE 'url\(http://[^)]+\)' | sort -u
Fix
- Replace
http://withhttps://(or a relative URL such as/js/app.js) in templates, CSS and JavaScript. - Update the CMS: set the site address to
https://and run its search-and-replace for old content in the database, with a backup first. - Pass the scheme behind a proxy:
proxy_set_header X-Forwarded-Proto $scheme;, and tell the application to trust it. - As a stopgap, send
Content-Security-Policy: upgrade-insecure-requestsso the browser upgrades requests that the server supports over HTTPS. - Replace third-party resources that have no HTTPS version.
Typical scenario
You moved a WordPress site to HTTPS with Let's Encrypt and the certificate works. Still the home page appears without layout, and the browser console says "Mixed Content: … requested an insecure script 'http://example.com/wp-content/…'". The theme or the database still holds old absolute http addresses. Open the console (F12) and note the first blocked URLs; they show whether a theme, plugin or stored content is the source.
FAQ
Why are some mixed resources only warned and others blocked?
Browsers treat scripts, styles and requests (active content) as blocked, and images, audio and video (passive content) more leniently, or upgrade them. Rely on neither: fix all of them.
Is upgrade-insecure-requests a real fix?
It works only when the target also exists on HTTPS. It is a good safety net, but the URLs should still be corrected at the source.
How do I find all mixed-content addresses of a page?
Open the developer tools and read the console: it lists every blocked or upgraded address. In the Network tab you can filter for http:// requests. For many pages a crawler that searches the output for http:// helps; remember content that is only loaded later by JavaScript.
Do ordinary links to http pages count as mixed content?
No. Only resources that the page itself loads are affected: scripts, stylesheets, images, fonts, iframes and requests made from JavaScript. A link a visitor clicks is only loaded on click and is not mixed content. It should still point to https if the target offers it.
How do I replace the addresses in the WordPress database safely?
With WP-CLI: wp search-replace 'http://example.com' 'https://example.com' --dry-run shows beforehand what would change. WP-CLI also handles serialized data correctly, which a plain SQL REPLACE can break. Make a backup first and run it without --dry-run only afterwards.