Error fixes
Fix Mixed Content Errors After Enabling HTTPS
A mixed content error means a page loaded over HTTPS is still requesting something, an image, script or stylesheet, over plain HTTP, so the browser blocks or flags it. Find each offending URL in the DevTools console, change it to HTTPS at its source, and use a CSP upgrade rule only as a safety net.
By CodingMarble · Published · 4 min read

What the console is telling you
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.
Mixed Content: The page at 'https://example.com/' was loaded over HTTPS,
but requested an insecure image 'http://example.com/img/logo.png'.
This content should also be served over HTTPS.Enabling a certificate secures the connection to your page, but the page is made of many separate requests. Any of them that still starts with http:// is an unprotected hole in an otherwise protected page, because an attacker on the network can alter an HTTP response. Browsers therefore treat the page as not fully secure, and the padlock may disappear or show a warning.
Browsers split the problem in two. Passive mixed content, such as images, audio and video, can only change how the page looks, so many browsers load it with a warning or try to upgrade it automatically. Active mixed content, such as scripts, stylesheets, iframes and fetch or XHR calls, can rewrite the whole page, so modern browsers block it outright. That is why a broken layout or missing script is the first symptom people notice. Exact behaviour varies by browser and version, so test in the browsers your visitors use.
Find every offending request
Open DevTools on the HTTPS page and read the Console: each mixed content message names the page and the exact URL. Then open the Network tab, reload, and filter by text with http: to catch requests that were silently upgraded or did not log a message. Check pages beyond the home page, since a blog post template, a checkout page or an embedded map may load different resources.
const attrs = ["src", "href", "data-src", "poster", "action"];
const found = new Set();
document.querySelectorAll("*").forEach((el) => {
attrs.forEach((a) => {
const v = el.getAttribute(a);
if (v && v.trim().toLowerCase().startsWith("http://")) {
found.add(el.tagName.toLowerCase() + " " + a + " -> " + v);
}
});
});
console.table([...found]);This only sees what is in the current DOM, so it misses URLs inside CSS files (background images and font sources), inline style blocks you did not scan, and requests that scripts create later. Treat it as a quick triage list alongside the Network tab rather than a full audit.
Fix the URL where it is written
The durable fix is to change the address where it lives. In templates, theme files and stylesheets, replace http://yourdomain.com/path with https://yourdomain.com/path, or with a root-relative path such as /img/logo.png, which follows whatever scheme the page used. For third-party resources, check that the provider supports HTTPS and use its https address; if a provider has no HTTPS version at all, replace or remove it, because you cannot fix that from your side.
Protocol-relative URLs, those starting with //, were once recommended as a trick. They are not the answer today: they hide the scheme instead of stating it, they produce odd results when a file is opened locally, and the web has settled on HTTPS everywhere, so write https:// explicitly.
Content from a content management system often stores absolute URLs in the database, which is why a template can look clean while old posts still break. Embedded images inside post bodies, widget text, custom fields and plugin settings all keep the address they had when written.
WordPress and database content
First set the WordPress Address and Site Address to https in Settings, General, or in wp-config.php. Then replace stored URLs in content. Do not run a raw SQL replace on a WordPress database: some values are PHP-serialised, where each string records its own length, and changing the text without fixing the length corrupts the value. Use a tool that understands serialised data, such as WP-CLI's search-replace command or a reputable plugin, and take a full backup first.
wp db export backup-before-https.sql
wp search-replace 'http://example.com' 'https://example.com' --dry-run --all-tables
wp search-replace 'http://example.com' 'https://example.com' --all-tables
wp cache flushPractical tip: the dry run prints how many replacements it would make per table. If the numbers look wildly higher than you expect, or touch tables you do not recognise, stop and investigate before running the real command. Also clear any page cache, CDN cache and minified or combined asset files afterwards, because they keep serving the old addresses.
Check plugin and theme settings too: some store a logo URL, an analytics script or a font link in their own options. Content delivery network and caching plugins often have a separate setting for the CDN address that also needs the https scheme, and a CDN hostname that has no certificate will itself cause errors, so verify it loads over HTTPS in a browser.
The CSP safety net and HSTS
The Content-Security-Policy directive upgrade-insecure-requests tells the browser to rewrite http subresource URLs to https before requesting them. It is a useful backstop while you clean up, and it can be set in a response header or a meta tag.
Content-Security-Policy: upgrade-insecure-requestsTreat it as a net, not a fix. It only helps if the resource actually exists at the https address; if the third party serves nothing there, the request simply fails instead of loading. It adds no help for links that visitors click, and it can hide problems from your own testing, so fix the sources and use the directive as protection against what you missed.
Once every page loads cleanly, consider HSTS, the Strict-Transport-Security header, which tells browsers to use HTTPS for your domain without first trying http. Roll it out gradually: start with a short max-age, confirm nothing breaks, and extend it. Be careful with the includeSubDomains option and with preload, since both affect hostnames you may not have secured yet and are hard to undo once browsers remember them. Read the current documentation before enabling either.
To confirm the fix, reload each key page with the console open and the cache disabled, and check that no mixed content messages remain and the padlock shows a secure connection. To prevent a repeat, reference assets by https or root-relative paths, review new embeds and plugins for http links before publishing, and include a console check in your release routine.
Keep reading
- Hosting and planningInstall a Free SSL Certificate and Enable HTTPSA free SSL certificate, usually from Let's Encrypt, encrypts traffic between visitors and your server and proves your domain is yours. On shared hosting it is typically a one-click setting, and on a VPS you can issue and renew it with certbot and nginx.
- Web developmentWebsite Security Basics for Small BusinessesMost small business sites are compromised through outdated plugins, weak or reused passwords and missing basic server settings, not through clever attacks. Cover HTTPS, updates, authentication, security headers, form handling and tested backups, and you remove the common routes in.
- Web developmentTechnical SEO Checklist for a New WebsiteTechnical SEO makes sure search engines can find, read and index your pages. Check crawlability, indexability, page titles, headings, internal links, structured data and mobile speed, confirm the result in Search Console, and accept that new domains take time to appear.
- Error fixesFix CORS Error: No Access-Control-Allow-Origin HeaderThe browser blocked a cross-origin request because the server's response did not include permission for your page's origin, in the form of an Access-Control-Allow-Origin header. The fix always lives on the server (or in a proxy you control), not in the front-end fetch call.
Need this built properly for your business?
CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.
- On CodingMarble
- WordPress development
- Website maintenance services
- All guides