Troubleshooting

The website is not shown as secure with HTTPS (mixed content)

Reviewed on 5 min read mixed content SSL

We assume your website is already set up to use https:// with its SSL certificate. Normally the browser shows it as secure:

Browser showing the website's connection as secure

But sometimes, even though the address starts with https://, the browser shows a warning, or the website looks "broken" because the stylesheets, images or JavaScript files do not load:

HTTPS website that the browser does not show as secure because of mixed content

This is what is called mixed content: the page loads over HTTPS, but inside it has links to images, CSS, JavaScript or other resources that are requested over http://. Browsers block scripts and styles that arrive over HTTP, and until all resources load over HTTPS they do not show the website as secure.

Find the resources with http://

Open the website in Chrome or Firefox, press F12 and go to the Console tab. Reload the page: each problem resource appears with a "Mixed Content" warning and its full http:// address. We explain this in more detail in how to use the browser console.

With that list you know what needs fixing. The links are usually in:

  • The application's database (page and post content, settings with the website's URL).
  • The theme or template files, including the CSS (for example, a background image with url(http://...)).
  • Resources from other websites (fonts, scripts, external images).

Fix it in WordPress

  1. In Settings > General, check that WordPress Address (URL) and Site Address (URL) start with https://.

  2. Change the old links in the database with the Better Search Replace plugin. In Tools > Better Search Replace:

    • Search for: http://tudominio.com
    • Replace with: https://tudominio.com
    • Select all the tables.
    • First do a pass with Run as dry run? ticked to see how many changes it will make, then untick it and run it.

    Repeat with http://www.tudominio.com if your website used www. Make a backup of the database first. This plugin respects WordPress's serialised data; do not do it with an UPDATE in phpMyAdmin, because you would break it.

    If you have SSH access, you can do the same with WP-CLI:

wp search-replace 'http://tudominio.com' 'https://tudominio.com' --all-tables --dry-run
wp search-replace 'http://tudominio.com' 'https://tudominio.com' --all-tables
  1. Clear the WordPress cache (caching plugin) and the browser cache, and look at the console again.

If warnings remain, they usually come from the theme or a plugin with the address written in its code or CSS: fix it in that file or in the theme settings.

As a quick fix while you correct the source, the SSL Insecure Content Fixer plugin rewrites http:// links to https:// when serving the page. In its settings (Settings > SSL Insecure Content), start with the Simple level and move up to Content or Widgets if that is not enough.

Fix it on any other website

For any application (PrestaShop, Joomla, a hand-built website…), change the http:// links the console shows in the configuration, the database or the theme files.

In the meantime, you can ask the browser to load all the page's resources over HTTPS by adding this line at the top of the website's .htaccess file:

Header always set Content-Security-Policy "upgrade-insecure-requests"

It only works with resources that are also available over HTTPS. If an external website does not have HTTPS, that resource will still not load: download it and upload it to your hosting, or replace it with another one.

Check that it works

Open the website again with the console open: there should be no "Mixed Content" warnings left and the browser should show the connection as secure. Also check some internal pages, the contact form and, if it is a shop, the cart.

You may also find useful

Something wrong or out of date? Tell us and we will review it.