Fix "Mixed Content: … requested an insecure resource" (HTTPS mixed content)
Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure resource 'http://example.com/api/users'. This request has been blocked; the content must be served over HTTPS.
- Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure script 'http://cdn.example.com/app.js'. This request has been blocked; the content must be served over HTTPS.
- Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://example.com/css/app.css'. This request has been blocked; the content must be served over HTTPS.
- Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure element 'http://example.com/img/logo.png'. This request was automatically upgraded to HTTPS.
- Blocked loading mixed active content “http://example.com/js/app.js”
- Mixed Content: The page at 'https://example.com/login' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'http://example.com/login'.
Your page is served over HTTPS but loads a script, stylesheet, API call or form over http://, and the browser blocks that request. Replace the http:// URLs with https:// (or relative paths) and, behind a proxy or Cloudflare, make the application aware it runs over HTTPS so it generates the right URLs.
What this error means
An HTTPS page guarantees its content was not read or modified in transit. If it loads a resource over plain HTTP, an attacker on the network could replace that script or API response and take over the page. Browsers therefore block "active" mixed content (scripts, CSS, fetch, iframes, form targets). For images, audio and video, Chrome tries an automatic upgrade to HTTPS and no longer displays them if the server does not answer over HTTPS. The error always names the offending URL: that is what you need to fix, in the code or in the configuration that generates it.
Common causes
- Application behind a proxy, load balancer or Cloudflare: the proxy terminates HTTPS and talks HTTP to the application, which then generates
http://URLs (assets, redirects,url()). - Hard-coded URLs in code or configuration:
APP_URL=http://…, aVITE_API_URLorNEXT_PUBLIC_API_URLvariable set tohttp://, a<script src="http://…">tag. - Content stored in the database: a site moved to HTTPS (WordPress, CMS) whose posts still contain
http://images and links. - Third-party resource without HTTPS: an old CDN, widget or API that only answers over HTTP.
Step-by-step fix
-
Find the offending URLs
Open DevTools (F12) > Console: each message gives the blocked URL. Then check that the resource is really available over HTTPS.
curl -sI https://example.com/api/users | head -n 1 -
Fix the URLs in the code
Replace
http://withhttps://, or use a relative path (/api/users) for resources on your own domain. Also look in the.envfiles used at build time.grep -rn "http://" src/ resources/ .env* --exclude-dir=node_modules -
Laravel behind a proxy: trust the headers
The proxy sends
X-Forwarded-Proto: https. Laravel only reads it if the proxy is trusted (Laravel 11+ inbootstrap/app.php). Also setAPP_URL=https://example.com. Only trust*if the application can only be reached through the proxy; otherwise list its IP addresses.// bootstrap/app.php ->withMiddleware(function (Middleware $middleware) { $middleware->trustProxies(at: '*'); }) // app/Providers/AppServiceProvider.php, in boot() if ($this->app->environment('production')) { \Illuminate\Support\Facades\URL::forceScheme('https'); } -
WordPress or CMS: rewrite the URLs in the database
With WP-CLI, replace the old URL across the whole database (back it up first).
--dry-runfirst shows what would change.wp db export backup.sql wp search-replace 'http://example.com' 'https://example.com' --all-tables --dry-run wp search-replace 'http://example.com' 'https://example.com' --all-tables -
Safety net: upgrade-insecure-requests
This CSP directive tells the browser to upgrade every request of the site to HTTPS. It only works if the resources exist over HTTPS, and it does not replace fixing the URLs.
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Never hard-code the protocol for your own resources: use relative paths or the framework helpers (
asset(),url(),@vite). - Enable HSTS (
Strict-Transport-Security) once the whole site is on HTTPS, so the browser never uses HTTP again. - Test your staging environment over HTTPS, behind the same kind of proxy as production.
Frequently asked questions
Why does it work locally but not in production?
Locally you are often on http://localhost, so nothing is mixed. In production the page is HTTPS and every http:// resource gets blocked, especially if the application behind a proxy still thinks it runs over HTTP.
Can I allow mixed content in the browser?
Chrome lets you allow it per site (Site settings > Insecure content), but only for you and at the cost of exposing the page to code injection. It is not a fix for your visitors: correct the URLs.
What if the third-party API only exists over HTTP?
Call it from your server (a back-end proxy route) and expose the result over HTTPS on your own domain, or pick another provider.
Useful tools for this error
Error finder
Paste an error message or a log: the tool recognises the error and opens the right fix.
HTTP status codes
All the common HTTP codes (401, 403, 404, 419, 429, 500, 502…): meaning, causes and what to do.
cURL converter
Paste a cURL command (DevTools “Copy as cURL”): get the fetch, axios, Node, PHP (Laravel Http or curl) or Python requests code.
More Web, HTML & CSS errors
- Fix "Refused to apply style … MIME type ('text/html') is not a supported stylesheet MIME type"
- Fix "Failed to load module script: Expected a JavaScript module script … MIME type of text/html" (Vite, SPA)
- Fix "Refused to execute inline script because it violates the following Content Security Policy directive"
- Fix ERR_TOO_MANY_REDIRECTS "redirected you too many times" (redirect loop)
- Fix "Your connection is not private" NET::ERR_CERT_DATE_INVALID and ERR_CERT_AUTHORITY_INVALID
- Fix "ResizeObserver loop completed with undelivered notifications"
- Fix net::ERR_BLOCKED_BY_CLIENT (ad blocker, analytics, "ads" files)