localhost:443
Port 443 is HTTPS — the secure version of HTTP. When you see the padlock in your browser, traffic flows through port 443. For local development, you'll need to set up SSL certificates to use https://localhost.
HTTP vs HTTPS
| Feature | HTTP (Port 80) | HTTPS (Port 443) |
|---|---|---|
| Encryption | None | TLS/SSL encrypted |
| URL prefix | http:// | https:// |
| Certificate | Not required | Required |
| Browser | "Not secure" warning | Padlock icon |
Local HTTPS with mkcert
Easiest way to get trusted HTTPS on localhost:
# Install mkcert
# Mac
brew install mkcert
# Windows (with Chocolatey)
choco install mkcert
# Create local CA
mkcert -install
# Generate localhost certificate
mkcert localhost 127.0.0.1 ::1
# Creates: localhost+2.pem and localhost+2-key.pem
Use with Node.js
const https = require('https');
const fs = require('fs');
const options = {
key: fs.readFileSync('localhost+2-key.pem'),
cert: fs.readFileSync('localhost+2.pem')
};
https.createServer(options, (req, res) => {
res.end('Secure!');
}).listen(443); // Needs sudo
Vite HTTPS
// vite.config.js
import fs from 'fs';
export default {
server: {
https: {
key: fs.readFileSync('localhost+2-key.pem'),
cert: fs.readFileSync('localhost+2.pem')
}
}
}
Why Use HTTPS Locally?
- Test features that require HTTPS (Service Workers, Geolocation, Clipboard API)
- Avoid mixed content warnings
- Match production environment
- OAuth callbacks often require HTTPS