Skip to content
Mail Cabinet Choose a plan

How to Fix Mixed Content After Switching to HTTPS

How to Fix Mixed Content After Switching to HTTPS

Mixed content means resources with http:// addresses on a page served over HTTPS. In our test, Chromium 141 upgraded images to HTTPS on its own, but blocked http:// stylesheets, scripts and iframes outright, which is what breaks the layout, buttons and forms. The fix: replace the URLs in the database with wp search-replace (run it with --dry-run first), find hardcoded http:// in theme and plugin code, move resources that have no HTTPS to your own hosting, and keep the upgrade-insecure-requests header as a safety net.

If the browser says “Your connection is not private” on every page, mixed content is not the issue: the certificate itself is, so start there (installation, checks and common errors are covered in SSL certificate on shared hosting). This article covers the case where the certificate is fine but pages still pull something over HTTP.

How we tested

RichHost test bench: isolated container with 2 vCPU / 8 GB, Ubuntu 24.04, nginx 1.24, PHP 8.3-FPM, MariaDB 10.11, WordPress 6.7.2, 25 October 2026. We copied the WordPress files and database and served the copy from a separate nginx server block (port 8443, self-signed certificate, domain mixed.test), leaving the main bench site untouched. The test post contained an image, a stylesheet, a script and an iframe with http:// URLs, a logo in a serialized option, a stylesheet hardcoded in PHP (a mu-plugin) and a script from a separate “CDN” that only speaks HTTP. We loaded the page in headless Chromium 141.0.7390.37 (Playwright), recorded console messages and the outcome of every request, and repeated the test after each fix. The test block, database copy and files were deleted afterwards.

What the browser does with HTTP resources: test results

The console before any fixes (shortened, duplicate lines removed):

warning: Mixed Content: The page at 'https://mixed.test:8443/mixed-content-test/' was loaded over HTTPS,
  but requested an insecure element 'http://mixed.test:8443/wp-content/uploads/2026/10/r15-test.png'.
  This request was automatically upgraded to HTTPS, ...
error: Mixed Content: ... requested an insecure stylesheet 'http://mixed.test:8443/wp-content/r15/box.css'.
  This request has been blocked; the content must be served over HTTPS.
error: Mixed Content: ... requested an insecure script 'http://mixed.test:8443/wp-content/r15/app.js'.
  This request has been blocked; the content must be served over HTTPS.
error: Mixed Content: ... requested an insecure script 'http://nohttps-cdn.test:8088/widget.js'.
  This request has been blocked; the content must be served over HTTPS.
error: Mixed Content: ... requested an insecure frame 'http://mixed.test:8443/wp-content/r15/frame.html'.
  This request has been blocked; the content must be served over HTTPS.

Yellow warnings mean the browser requested the same URL over HTTPS by itself. Red errors mean the request was never sent: the stylesheet did not apply (the block lost its background), the script did not run, the iframe stayed empty. Here is how the page behaved after each step:

Resource on the page No fixes upgrade-insecure-requests header only After wp search-replace After code and CDN fixes
Image in post content upgraded to HTTPS, shown shown shown shown
Logo from an option (serialized array) upgraded to HTTPS, shown shown shown shown
Stylesheet in the post (link rel=”stylesheet”) blocked loaded loaded loaded
Own script (script src) blocked ran ran ran
iframe blocked loaded loaded loaded
Stylesheet hardcoded in PHP (wp_enqueue_style with http://) blocked loaded blocked loaded
Script from a third-party host without HTTPS blocked ERR_SSL_PROTOCOL_ERROR blocked ran (file moved to own site)
Mixed Content lines in the console 9 0 (plus 1 load error) 2 0

Two findings most guides skip. First, although the site address in the database was still http://, WordPress’s own styles and scripts came over HTTPS, because WordPress uses the scheme of the current request. So it is not core that breaks the page but URLs in post content, options and theme code. Second, the browser “repairs” images itself, so the yellow warnings are easy to ignore, but they tell you old URLs are still in the database.

Symptom, cause, fix

What you see Most likely cause What to do
“Not secure” warning on a page with a form or when submitting it The form posts to http:// (console: “contains a form that targets an insecure endpoint”) Change the form action to https:// or a relative path; check the form plugin settings
Connection-not-private warning on every page A certificate problem, not mixed content Check the certificate first: chain, expiry, domains it covers
Broken layout, unstyled blocks http:// stylesheets blocked (blocked stylesheet) wp search-replace across all tables; if anything remains, look in theme code
Slider, menu, button or form not working Blocked script Same: database, then code; for a third-party script check its HTTPS URL
Error persists after the database replace and wp db search finds nothing URL hardcoded in theme or plugin PHP, CSS or JS grep through wp-content, fix in a child theme or update the plugin
CDN or widget resource fails even with upgrade-insecure-requests The third-party server has no HTTPS Host the file yourself or replace the service; the header cannot help
Blank space instead of a map or video http:// iframe Get a fresh https:// embed code from the service

Fix 1: replace URLs in the database with WP-CLI

Backup first, then a dry run, and only then the real replace. Real output from the bench (use your domain instead of mixed.test:8443):

$ wp db export before-https.sql
Success: Exported to 'before-https.sql'.

$ wp search-replace 'http://mixed.test:8443' 'https://mixed.test:8443' --all-tables --precise --skip-columns=guid --report-changed-only --dry-run
Table       Column        Replacements  Type
wp_options  option_value  3             PHP
wp_posts    post_content  3             PHP
wp_users    user_url      1             PHP
Success: 7 replacements to be made.

$ wp search-replace 'http://mixed.test:8443' 'https://mixed.test:8443' --all-tables --precise --skip-columns=guid --report-changed-only
...
Success: Made 7 replacements.

$ wp cache flush

The Replacements column counts changed table rows, not every occurrence: our test post contained four site URLs, yet it is one of the three post_content rows in the report. On the bench database copy the replace took 0.33 s. The command fixes the home and siteurl options along with everything else. We skip the guid column: it is an RSS identifier, not a URL the browser loads.

Why not plain SQL. We checked it on a separate test option holding the same logo:

# after wp search-replace the length in the serialized data was updated (62 -> 63)
a:2:{s:4:"logo";s:63:"https://mixed.test:8443/wp-content/uploads/2026/10/r15-test.png";...}

# after UPDATE ... REPLACE(option_value, 'http://', 'https://')
a:1:{s:4:"logo";s:62:"https://mixed.test:8443/wp-content/uploads/2026/10/r15-test.png";}
$ wp eval 'var_dump( get_option("r15_sqltest") );'
bool(false)

The string grew by one character but the stored length did not change, so WordPress cannot unserialize the value and returns false: the theme or widget setting simply disappears. Without SSH, use a search-and-replace plugin that handles serialized data and offers a dry run; the logic is the same.

WordPress’s built-in HTTPS switch: what it fixes

When you change the site address from http:// to https:// in the settings (we did it with wp option update home on a restored database copy), WordPress sets the https_migration_required flag and rewrites old URLs of its own domain in post content on the fly. The test showed where this stops:

$ wp option get https_migration_required
1
$ wp db query "SELECT COUNT(*) FROM wp_posts WHERE post_content LIKE '%http://mixed.test:8443%'"
3
$ curl -s https://mixed.test:8443/mixed-content-test/ | grep -Eo '(src|href)=["\']http://[^"\' ]+' | sort -u
href='http://mixed.test:8443/wp-content/r15/theme.css?ver=6.7.2
src="http://mixed.test:8443/wp-content/uploads/2026/10/r15-test.png
src="http://nohttps-cdn.test:8088/widget.js

The stylesheet, script and iframe in the post content started working, but three posts still contain http:// in the database, and the logo from the option, the stylesheet from PHP code and the third-party script still go over HTTP. It is an output-time patch, not a substitute for wp search-replace.

Fix 2: URLs hardcoded in theme and plugin code

After the database replace, two errors remained on our page. Searching wp-content for http:// returns a lot of noise: Akismet, for example, calls its API over HTTP from the server, which is not mixed content because the browser never sees those requests. So search for your own domain:

$ grep -rInE "http://(www\.)?mixed\.test" wp-content/themes wp-content/plugins wp-content/mu-plugins
wp-content/mu-plugins/r15-hardcoded.php:4:  wp_enqueue_style('r15-theme', 'http://mixed.test:8443/wp-content/r15/theme.css');

Change what you find to https:// or to a relative /wp-content/… path, and do it in a child theme: a parent theme update will wipe your edits. If the URL is in a plugin, update it or contact the developer.

Fix 3: a third-party resource without HTTPS

Before switching the scheme, check whether the third-party server answers over HTTPS. On the bench the “CDN” only spoke HTTP, and curl failed with a TLS error (exit code 35). So we moved the file to our own site and replaced the URL in post content only:

$ curl -sI https://nohttps-cdn.test:8088/widget.js; echo "exit: $?"
exit: 35
$ curl -s -o wp-content/r15/widget.js http://nohttps-cdn.test:8088/widget.js
$ wp search-replace 'http://nohttps-cdn.test:8088/widget.js' 'https://mixed.test:8443/wp-content/r15/widget.js' wp_posts --include-columns=post_content --report-changed-only
Table     Column        Replacements  Type
wp_posts  post_content  1             SQL
Success: Made 1 replacement.

After that, a repeat run in Chromium showed zero Mixed Content messages and no blocked requests. For scripts that must stay current (counters, chat widgets) self-hosting does not work: find a service with HTTPS.

Safety net: upgrade-insecure-requests in nginx

The Content-Security-Policy: upgrade-insecure-requests header tells the browser to request every http resource of the page over HTTPS. In the test it removed all blocks on its own, except for the third-party host without HTTPS, where the browser got ERR_SSL_PROTOCOL_ERROR. The tested snippet:

# /etc/nginx/snippets/https-headers.conf
add_header Content-Security-Policy "upgrade-insecure-requests" always;

server {
    listen 443 ssl;
    ...
    include snippets/https-headers.conf;

    location ~ \.php$ {
        ...
        add_header X-Cache $upstream_cache_status always;  # own add_header in this location
        include snippets/https-headers.conf;              # so the header must be repeated
    }
}

The trap we reproduced: once a location has any add_header of its own, server-level headers no longer apply inside it. On the bench a static file got the CSP header and WordPress pages did not:

# server{} has the CSP, location ~ \.php$ has its own add_header
$ curl -sI https://mixed.test:8443/mixed-content-test/ | grep -iE "content-security|x-powered-note"
X-Powered-Note: php-location
$ curl -sI https://mixed.test:8443/wp-content/r15/frame.html | grep -iE "content-security|x-powered-note"
Content-Security-Policy: upgrade-insecure-requests
# after the include in both places
$ curl -sI https://mixed.test:8443/mixed-content-test/ | grep -iE "content-security|x-powered-note"
X-Powered-Note: php-location
Content-Security-Policy: upgrade-insecure-requests

Without access to the server config, a meta tag in <head> does the same: <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">. We checked it on a separate page: the http script loaded over HTTPS and ran. For Apache it is Header always set Content-Security-Policy "upgrade-insecure-requests" in .htaccess (the bench runs nginx, so we did not run this variant). The HTTP-to-HTTPS redirect is a separate task; ready rules are in 301 redirect in .htaccess and Nginx.

How to find leftovers after the fix

# 1. Page HTML: what still loads over http://
curl -s https://example.com/page/ | grep -Eo '(src|href)=["\']http://[^"\' ]+' | sort -u

# 2. Posts that still have http:// in src/href
wp db query "SELECT ID, post_type FROM wp_posts WHERE post_content REGEXP '(src|href)=.http://' AND post_status='publish'"

# 3. Options containing http:// (on the bench only ping_sites matched: server-side pings, not mixed content)
wp db query "SELECT option_name FROM wp_options WHERE option_value LIKE '%http://%'"

# 4. All tables: only the guid column should remain
wp db search 'http://example.com' --all-tables --stats

Then clear the plugin, server and CDN caches and walk through the home page, a post, a category, search and pages with forms with the console open. If the site behind a proxy starts bouncing between URLs after the HTTPS switch, you are dealing with an ERR_TOO_MANY_REDIRECTS redirect loop.

FAQ

Is the upgrade-insecure-requests header enough on its own?

Temporarily, yes, if every resource has an HTTPS version. But the old URLs stay in the HTML, and the header cannot save a resource without HTTPS: in our test such a script simply did not load. A clean database plus the header as a safety net is more reliable.

Why do images show while the console has yellow warnings?

Chromium requests the image over HTTPS itself and shows it if the file exists at the HTTPS URL. If there is no HTTPS version, the image will not appear. The warning means old URLs are still in the database: run wp search-replace.

Can I replace http with https using an SQL REPLACE query?

Only in post_content, where data is not serialized. In wp_options and wp_postmeta such a query breaks serialized strings: in our test the option returned false afterwards.

Do I need to reissue the certificate?

No, mixed content appears after the certificate already works. Reissue only if the browser complains about the certificate itself.

All RichHost hosting plans include free Let’s Encrypt SSL, managed in our own control panel with an AI assistant. Mixed content is then fixed with the sequence above: database, code, third-party resources, header.

More on this topic

All articles
Cloudflare Setup Guide: DNS, SSL, Caching and Bot Protection
Domains and DNS16.11.2026

Cloudflare Setup Guide: DNS, SSL, Caching and Bot Protection

Cloudflare setup on the Free plan, tested on a bench: the Flexible loop in WordPress, SSL modes Off, Flexible, Full and Full…

WordPress 404 on All Pages Except Homepage: How to Fix It
Hosting Troubleshooting12.11.2026

WordPress 404 on All Pages Except Homepage: How to Fix It

WordPress 404 on all pages except the homepage: six causes reproduced on a test bench, real response codes, a decision table and…

403 Forbidden Error: What It Means and How to Fix It
Hosting Troubleshooting12.11.2026

403 Forbidden Error: What It Means and How to Fix It

What a 403 Forbidden error means and how to find the cause: file permissions, .htaccess, nginx, IP blocks, hotlink protection, WAF and…