How to Run HTTPS on Localhost for WordPress Development

Quick answer: Run HTTPS on localhost for WordPress by using a trusted local certificate tool or a development environment that creates certificates for you, then set the WordPress Address and Site Address to the HTTPS local URL. After that, check mixed content, cookies, redirects, and hardcoded HTTP links.

Local HTTPS is useful when a WordPress project needs to behave like production. Login cookies, payment callbacks, OAuth, service workers, secure embeds, some APIs, and browser permissions can behave differently on HTTP. If the live site uses HTTPS, the local development site should usually use HTTPS too.

Choose a local development setup

The easiest route is a WordPress development tool that supports SSL certificates automatically. Local, DevKinsta, DDEV, Lando, Docker-based stacks, and custom Nginx or Apache setups can all work. The best choice is the one your team can reproduce and document.

If your tool has a trust SSL or enable HTTPS button, use it. If you build your own stack, use a local certificate authority tool such as mkcert. The goal is for the browser to trust the certificate so you are not testing through warnings every day.

Set the WordPress URLs correctly

In wp-admin, set WordPress Address and Site Address to the local HTTPS URL, such as https://example.test. You can also define WP_HOME and WP_SITEURL in wp-config.php for local environments. Keep the local domain consistent. Switching between localhost, 127.0.0.1, and example.test can create cookie and redirect confusion.

Fix mixed content

Mixed content happens when an HTTPS page loads images, scripts, stylesheets, or embeds over HTTP. In WordPress, this often comes from old content, hardcoded theme URLs, plugin settings, or imported database values. Use browser developer tools to find the exact asset. Then update the content, option, or code that produced it.

Do not solve local mixed content by disabling browser security. That hides a real production problem. If a URL should be HTTPS in production, make it HTTPS locally too.

Watch for redirect loops

HTTPS redirect loops often happen when WordPress, a plugin, and the local web server all try to force SSL in different ways. Decide which layer controls redirects in local development. If the browser keeps bouncing between HTTP and HTTPS, check server config, WordPress URL settings, security plugins, and any code that inspects forwarded protocol headers.

Cookies and login problems

If wp-admin keeps logging you out, clear cookies for the local domain and confirm the domain, port, and protocol are stable. A cookie set for https://example.test may not behave the same on http://localhost:8888. Keep one canonical local URL and use it everywhere.

When local HTTPS matters most

  • Testing WooCommerce checkout or payment provider callbacks.
  • Building membership or login-heavy sites.
  • Working with OAuth or third-party APIs.
  • Testing service workers or browser permissions.
  • Debugging mixed content before launch.
  • Matching a production HTTPS redirect setup.

Practical checklist

Create a local domain, generate and trust a local certificate, configure Apache or Nginx for HTTPS, update WordPress URLs, clear cookies, flush permalinks if needed, inspect the page for mixed content, and document the setup for the next developer. If using Docker or a local tool, commit the environment configuration but keep private keys and machine-specific paths out of the repository.

Final recommendation

Use local HTTPS whenever the live WordPress site uses HTTPS or depends on secure browser behavior. The setup takes a little time, but it prevents confusing bugs later. A local site should be close enough to production that SSL, redirects, cookies, and assets can be tested before launch.