Gem httpslocal-dev

mkcert

Make locally trusted HTTPS certificates for development in one command.

Would you recommend mkcert?

No votes yet. Tried it? Be the first to say.

One vote per person. No account needed.

Overview

mkcert creates a local certificate authority, installs it in your system and browser trust stores, and issues certificates for localhost or any dev hostname. No more browser warnings.

Instead of

Self-signed certs and clicking through browser warnings

Reach for it when

You need HTTPS locally for cookies, OAuth callbacks, service workers or HTTP/2.

Key features

  • Local certificate authority

    mkcert -install creates a private CA and adds it to the system, browser (including Firefox) and Java trust stores.

  • Any names

    Issue certificates for localhost, custom hosts (myapp.test), wildcards (*.myapp.test) and IP addresses in one command.

  • Flexible output

    PEM files by default, PKCS#12 with -pkcs12, custom file names with -cert-file and -key-file.

  • Client certificates

    -client issues certificates for testing mutual TLS.

  • Cross-platform

    macOS, Linux and Windows.

In depth

How it works

mkcert generates a root certificate unique to your machine and installs it into the trust stores your browsers and tools use. Certificates it issues are signed by that root, so they're trusted locally, and only locally, without any warnings. The CA files live in the directory shown by mkcert -CAROOT.

Typical use

bash
mkcert -install
mkcert localhost 127.0.0.1 ::1 myapp.test "*.myapp.test"
# -> ./localhost+4.pem and ./localhost+4-key.pem

Use the files in your dev server. For example, with Vite:

ts
// vite.config.ts
import fs from 'node:fs';
export default {
  server: {
    https: {
      cert: fs.readFileSync('./localhost+4.pem'),
      key: fs.readFileSync('./localhost+4-key.pem'),
    },
  },
};

Good to know

  • Node.js doesn't use the system trust store by default; set NODE_EXTRA_CA_CERTS="$(mkcert -CAROOT)/rootCA.pem" so Node clients trust your local certificates.
  • Add the generated .pem files to .gitignore.
  • Run mkcert -uninstall to remove the CA from your trust stores.

Strengths

  • Real green-padlock HTTPS locally in under a minute, with no browser warnings to click through.
  • Lets you test features that need a secure context: secure cookies, service workers, OAuth redirects, HTTP/2 and WebAuthn.
  • Tiny, focused and written by a well-known Go security engineer.

Watch out for

  • Never share or commit rootCA-key.pem; anyone with it can create certificates your machine trusts.
  • Certificates only work on machines where the CA is installed; phones and other devices need it installed manually.
  • It's for development only, not for production certificates.

Try it in a few minutes

Terminal
brew install mkcert   # or choco install mkcert
mkcert -install
mkcert localhost 127.0.0.1 myapp.test

Alternatives

Self-signed with openssl

No install, but browsers warn and you have to manage the trust exceptions yourself.

Caddy's internal CA

tls internal in Caddy does something similar automatically for sites it serves.

step-ca

A full private CA with automation, for teams and internal infrastructure.

Related tools

Other tools that share topics with mkcert.

Renovate

docs.renovatebot.com
Gem

Automated dependency update PRs with grouping, schedules and automerge.

Instead of Manual upgrades, or Dependabot with one PR per package

Caddy

caddyserver.com
Gem

A web server and reverse proxy with automatic HTTPS.

Instead of nginx + certbot + cron renewal jobs

Kiri

runkiri.com
New

A small, fast container runtime for macOS, Windows and Linux that replaces Docker Desktop.

Instead of Docker Desktop