How to install HTTPS (not HTTP) on localhost on macOS Sequoia?

I tried to install HTTPS on current macOS version 15.5 using this way but with no success.

Is there something I’m missing?

  • http://localhost still working
  • https://localhost returns ERR_CONNECTION_REFUSED

I can give you all more information you need, below is the way I tried.

  1. I have isntalled current brew version 4.5.2

  2. brew install mkcert

  3. mkcert -install

  4. sudo nano /etc/ssl/localhost/localhost.conf

  5. I have put there

    [req]
    default_bits = 1024
    distinguished_name = req_distinguished_name
    req_extensions = v3_req
    
    [req_distinguished_name]
    
    [v3_req]
    basicConstraints = CA:FALSE
    keyUsage = nonRepudiation, digitalSignature, keyEncipherment
    subjectAltName = @alt_names
    
    [alt_names]
    DNS.1 = localhost
    
  6. sudo openssl genrsa -out /etc/ssl/localhost/localhost.key 2048

  7. sudo openssl rsa -in /etc/ssl/localhost/localhost.key -out /etc/ssl/localhost/localhost.key.rsa

  8. sudo openssl req -new -key /etc/ssl/localhost/localhost.key.rsa -subj /CN=localhost -out /etc/ssl/localhost/localhost.csr -config /etc/ssl/localhost/localhost.conf

  9. sudo openssl x509 -req -extensions v3_req -days 3650 -in /etc/ssl/localhost/localhost.csr -signkey /etc/ssl/localhost/localhost.key.rsa -out /etc/ssl/localhost/localhost.crt -extfile /etc/ssl/localhost/localhost.conf

  10. sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /etc/ssl/localhost/localhost.crt

  11. sudo apachectl restart

How to run HTTPS on localhost?