Skip to content

WordPress mixed content: find every http:// source and fix it

Mixed content on WordPress hides in options, serialized postmeta, theme files, plugin settings and third-party domains. The full diagnostic, with the commands and the output to expect at each step.

A mixed-content warning on WordPress is almost never one bad URL. It is a dozen, scattered across the options table, post content, serialized page-builder payloads, theme templates, plugin settings rows and a couple of third-party domains that still answer only on port 80. This guide is the complete hunt: how to read exactly what the browser blocked, where every http:// string can hide in a WordPress install, and how to change each one at its source without corrupting your database on the way.

What you’ll accomplish

  • Tell blocked active content apart from silently upgraded passive content, so you know which breakage is urgent and which is a time bomb.
  • Collect every violation across the whole site with a Content-Security-Policy-Report-Only header, instead of clicking through pages hoping to trip one.
  • Rewrite database URLs with wp search-replace in a way that survives PHP serialization, and understand exactly why the SQL shortcut destroys it.
  • Find the http:// strings that live in files, in uploads metadata and on third-party domains, where no database search-replace can reach.
  • End with a site that needs no upgrade-insecure-requests header holding it together.

Prerequisites

  • A valid TLS certificate already installed and serving on port 443. Mixed content is a content problem; it only appears after the certificate part works.
  • Shell access and WP-CLI 2.x. Confirm with wp --info, which prints the WP-CLI version and the PHP binary in use.
  • A database you can restore. Every rewrite step below assumes you took the dump in step 1.
  • Browser version matters. Chrome 86+ and Firefox 83+ upgrade passive mixed content to HTTPS before deciding to block it, so a current browser can look clean while an older one shows broken images. Read the console, not the padlock.
  • WordPress 5.7 and later ship an HTTPS check in Tools, Site Health with an “Update your site addresses” action. It rewrites only siteurl, home and post content. A fine first move, not a substitute for the rest of this guide.

How it works

Mixed content means the document was fetched over HTTPS but something on it was requested over plain HTTP. The browser does not treat all of those the same way, and the difference decides how loudly you find out.

Active content can change the page: scripts, stylesheets, iframes, XMLHttpRequest and fetch calls, web workers, and the target of a form element’s action attribute. A single injected script on a hijacked HTTP connection can rewrite the checkout form, so browsers refuse to send the request at all. You see a console error and a visibly broken page.

Passive content cannot execute anything: images, video and audio sources, favicons. The risk is that an observer learns what you loaded and can swap the pixels. Modern browsers retry the same URL over HTTPS first, and only if that fails does the asset disappear. Passive violations therefore often leave no visible trace, while the bad URL sits in your database.

Diagram comparing how browsers handle active and passive mixed content, showing which is blocked and which is auto-upgraded

The second half of the mechanism is storage. WordPress has no single place where URLs live: wp_options holds siteurl and home, wp_posts.post_content holds raw HTML, wp_postmeta holds PHP-serialized arrays where Elementor and Beaver Builder keep their JSON payloads and where _wp_attachment_metadata records every generated image size, and every plugin writes serialized settings rows of its own. Then there are theme templates, child-theme overrides, wp-config.php and must-use plugins on disk. A URL can hide in any of them.

Map of a WordPress install showing every storage location where an http URL can hide and the tool that finds each one

Step-by-step

  1. Take a database dump before anything rewrites it.

    wp db export ~/pre-mixed-content-$(date +%F).sql

    Expected output: Success: Exported to '/home/user/pre-mixed-content-2026-08-15.sql'. If it fails with mysqldump not found, the MySQL client tools are missing from PATH; add them and re-run, because every later step assumes this dump exists.

  2. Read the exact violation in the browser console. Open DevTools, reload with the Console tab open, and set the filter to Errors and Warnings. Chrome prints one line per violation naming both URLs:

    Mixed Content: The page at 'https://example.com/checkout/' was loaded over HTTPS,
    but requested an insecure script 'http://cdn.oldvendor.net/widget.js'.
    This request has been blocked; the content must be served over HTTPS.

    The word after “insecure” is the classification. script, stylesheet, frame and XMLHttpRequest mean blocked. element and image mean upgraded or warned. Copy the offending URL exactly; you are going to search for it.

  3. Collect violations site-wide with a report-only CSP. Clicking every page does not scale. Add a header that reports without enforcing. Apache, in the vhost or .htaccess:

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

    Nginx, in the server block:

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

    Confirm the header is live:

    curl -sI https://example.com/ | grep -i content-security-policy

    Expected output: one line beginning content-security-policy-report-only: echoing your policy. Point report-uri at an endpoint that logs the JSON body, or at a hosted collector. report-to is its official replacement, but report-uri still has the broader support, so send both if your collector accepts them. Leave it running for a week of real traffic before you call the list complete.

  4. Fix siteurl and home first. Everything WordPress generates at runtime is built from these two.

    wp option get siteurl
    wp option get home

    Expected output: two lines, ideally both https://example.com. If either still says http://, set them:

    wp option update siteurl 'https://example.com'
    wp option update home 'https://example.com'

    Expected output: Success: Updated 'siteurl' option. If instead you get Success: Value passed for 'siteurl' option is unchanged. while the site still serves HTTP URLs, the values are hard-coded as WP_SITEURL and WP_HOME constants in wp-config.php and the option is being ignored. Edit the file.

  5. Dry-run the database rewrite across every table.

    wp search-replace 'http://example.com' 'https://example.com' --dry-run --all-tables --report-changed-only --precise --skip-columns=guid

    Expected output: a table of Table, Column, Replacements, Type, ending with a line like Success: 148 replacements to be made. The Type column is the important one: rows marked PHP are serialized values that WP-CLI will unserialize, replace inside, and re-serialize, while SQL rows are plain strings. --all-tables reaches custom plugin tables that the default prefix filter skips. --precise forces the PHP path for every column instead of the fast MySQL substitution, which is what you want when serialized data is in play. --skip-columns=guid protects the post GUID, a permanent identifier that feed readers use to detect new posts.

  6. Understand why a raw SQL REPLACE() breaks this. PHP serializes a string as its type, its byte length, and its contents. A logo URL stored by a theme looks like this inside the wp_options value:

    a:1:{s:4:"logo";s:27:"http://example.com/logo.png";}

    s:27: says the next quoted string is 27 bytes, and http://example.com/logo.png is exactly 27 bytes. Run UPDATE wp_options SET option_value = REPLACE(option_value, 'http://', 'https://') and the string becomes 28 bytes while the prefix still claims 27. PHP’s unserialize() reads 27 bytes, finds the closing quote in the wrong place, and returns false. Your theme options, widget layout or Elementor page reverts to defaults and the builder shows an empty canvas. WP-CLI avoids this by unserializing before replacing and recounting the lengths on the way out. There is no safe raw SQL version of this operation.

  7. Run the rewrite for real.

    wp search-replace 'http://example.com' 'https://example.com' --all-tables --report-changed-only --precise --skip-columns=guid

    Expected output: the same table as the dry run, ending Success: Made 148 replacements. If the counts differ substantially from the dry run, something wrote to the database in between. Re-run the dry run and read the diff before continuing.

  8. Hunt the filesystem, which search-replace never touches.

    grep -rIn --include='*.php' --include='*.css' --include='*.js' 'http://example.com' wp-content/themes/ wp-content/plugins/ wp-content/mu-plugins/ wp-config.php

    Expected output: nothing at all on a clean install. Each hit is a file path, a line number and the line. Fix these at the source, and if the file belongs to a theme you did not write, move the change into a child theme so the next update does not undo it. Then widen the net to any host:

    grep -rIn --include='*.php' --include='*.css' 'src="http://' wp-content/themes/
  9. Check uploads metadata and page-builder payloads directly. These are the two places people declare victory too early. Find an attachment ID from the Media Library and read its metadata:

    wp post meta get 412 _wp_attachment_metadata

    Expected output: a PHP array dump with file, width, height and a sizes map. On a healthy install the file values are relative paths, not URLs; absolute http:// values here come from a migration plugin. For builder payloads, scan the meta table for survivors:

    wp db search 'http://example.com' wp_postmeta

    Expected output: nothing, or a list of table:column:row matches with the surrounding context highlighted. Any match here means a payload that the replacement missed, usually because the stored URL is JSON-escaped as http:\/\/example.com. Search for that form too:

    wp search-replace 'http:\/\/example.com' 'https:\/\/example.com' --dry-run --all-tables --precise
  10. Deal with third-party domains that genuinely have no HTTPS. Test the asset before assuming:

    curl -sI https://cdn.oldvendor.net/widget.js | head -1

    Expected output: HTTP/2 200, meaning the host does serve HTTPS and you simply rewrite the URL. A certificate error or a refused connection means no rewrite fixes it. Your three real options are to self-host the asset under wp-content/uploads/, replace the vendor, or drop the feature. Adding upgrade-insecure-requests here only turns a blocked request into a failed one.

  11. Purge every cache layer before you judge the result. A page cache, an object cache and a CDN can each hold HTML generated before the rewrite.

    wp cache flush

    Expected output: Success: The cache was flushed. Then purge the page cache from its plugin and the CDN from its own dashboard or API. Nothing you measure before this is meaningful.

Validate it works

Run all four checks. Each one covers a layer the others miss.

wp search-replace 'http://example.com' 'https://example.com' --dry-run --all-tables --report-changed-only --precise --skip-columns=guid

Expected output: Success: 0 replacements to be made.

grep -rIn --include='*.php' --include='*.css' --include='*.js' 'http://example.com' wp-content/ wp-config.php

Expected output: no lines, and an exit status of 1.

curl -s https://example.com/ | grep -o 'http://[^" ]*' | sort -u

Expected output: nothing, or only URLs that are protocol-explicit in prose rather than in an attribute. Repeat it against your three or four highest-traffic templates, not just the homepage.

Finally, load the site with the console open and click through a full purchase or form submission. Zero mixed-content lines is the pass condition. Leave the report-only CSP header in place for a week afterwards; an empty report log across real traffic is stronger evidence than any command above.

Troubleshooting

Search-replace reports zero, but the console still shows an http:// URL. The URL is not in the database. In order of likelihood: a stale page cache or CDN copy, a hard-coded URL in a theme file, or a URL built at runtime from $_SERVER['HTTPS']. Behind a reverse proxy that terminates TLS, that variable is unset on the origin and PHP concludes the request was plain HTTP. Fix it by trusting the forwarded header in wp-config.php, not by rewriting content.

The site broke after the rewrite, with blank widgets or an empty page builder. Serialized data was corrupted, which means the replacement did not go through WP-CLI. Restore the dump from step 1 with wp db import, then redo the rewrite using wp search-replace --precise. There is no forward fix; a broken length prefix cannot be recovered by another replacement.

Posts reappeared as new items in feed readers and email digests. The guid column was rewritten. GUIDs are opaque identifiers that only look like URLs, and subscribers key on them. Restore from the dump and re-run with --skip-columns=guid.

The admin redirects in a loop after updating siteurl. Either the two options now disagree, or WP_SITEURL and WP_HOME in wp-config.php contradict the database. Set both constants explicitly to the HTTPS form, load /wp-admin/ once, then decide whether to keep the constants. See forcing HTTPS on WordPress after an SSL install for the redirect rules that belong at the server level.

Fresh http:// URLs keep appearing in new posts. An editor is pasting them, or a plugin still holds an HTTP base URL that it stamps into content at save time. Check the plugin settings screens by hand. If the site also changed domains recently, work through running search-replace after a domain change first: a half-finished domain move produces the same symptom.

When this is the wrong approach

If the site sits behind a proxy with SSL terminated at the edge and plain HTTP to the origin, the database is innocent and no amount of search-replace will help. The origin genuinely serves HTTP, WordPress genuinely reports it, and the fix is at the proxy. That case has its own guide: mixed content behind a Cloudflare proxy.

If you do not yet have a working certificate, stop. Mixed content is the second problem, and fixing it first leaves you rewriting URLs that point somewhere unreachable.

If the install is a multisite network, every command here needs --url= on each site, and the network tables (wp_blogs, wp_site, wp_sitemeta) hold their own copies of the domain. Use wp site list --field=url to build the loop, and treat the network tables as a separate pass.

And upgrade-insecure-requests deserves one honest paragraph. Adding it to your CSP tells browsers to rewrite every HTTP subresource request to HTTPS before sending it. That makes the console go quiet in an afternoon. It is a bandage: the wrong URLs are still in your database, the assets on hosts with no HTTPS now fail instead of loading, and the day you migrate to a platform that does not carry the header the breakage returns all at once. Use it to buy a week while you work through the list above, then remove it and confirm the console is still clean without it.

For a full specification of what browsers classify as blockable, MDN’s mixed content reference is the source of truth, and the flags used here are documented in the WP-CLI search-replace reference.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.