How to Get Free SSL for Next.js
Free SSL for Next.js depends on where the app runs. A managed platform issues and renews the certificate for you; on a VPS, Nginx terminates TLS in front of the Node process.
Pick the setup that matches your hosting
| Where the app runs | Who handles TLS | What you do |
|---|---|---|
| Managed platform (Vercel, Netlify, Railway, Render) | The platform | Add your domain and point DNS. Check the platform docs for current certificate behavior. |
| Your own VPS | Nginx or Caddy in front of Node | Install a free Let's Encrypt certificate and proxy to port 3000. |
| Your laptop | A local dev certificate | Run next dev --experimental-https or use mkcert. |
For most teams, the managed platform is the least work. Platforms in this category normally issue and renew a certificate after you add a custom domain, but the exact rules differ, so read the current docs for yours. Our guide to free SSL on Railway, Render and Fly.io walks through that flow.
Free SSL for Next.js, option 1: managed hosting
- Add your domain in the platform dashboard.
- Create the DNS record the platform asks for, usually a CNAME for
wwwand an A or ALIAS record for the apex domain. - Wait for the certificate to be issued. This can take a few minutes after DNS resolves.
- Open
https://yourdomain.comand confirm the padlock.
If issuance stalls, the usual causes are a wrong DNS record, a leftover AAAA record that points elsewhere, or a CAA record that does not allow the issuing CA. Check those three first.
Free SSL for Next.js, option 2: VPS with nginx
Run Next.js on a local port and let Nginx handle HTTPS. Start the app with next start under a process manager such as systemd or PM2, then install a certificate with Certbot.
sudo apt install nginx certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
Certbot edits your Nginx config and sets up automatic renewal. Make sure the server block proxies to Next.js and passes the original protocol:
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
}
The X-Forwarded-Proto header matters. Without it, Next.js may build http:// URLs for redirects and absolute links, which leads to redirect loops or mixed content. If you use Caddy or Nginx Proxy Manager instead, see Fix SSL on Nginx Proxy Manager and Caddy.
Redirect HTTP to HTTPS
Certbot can add the port 80 redirect for you. If you prefer to do it in the app, use the redirects option in next.config.js with a has condition on the x-forwarded-proto header. Doing it at the proxy is simpler and cheaper, because the request never reaches Node.
Option 3: HTTPS on localhost
Recent Next.js versions can serve the dev server over HTTPS with a self-signed certificate that they generate and trust locally:
next dev --experimental-https
This flag is marked experimental, so confirm it exists in your installed version with next dev --help. If it does not, install mkcert, run mkcert -install, create a certificate for localhost, and pass it to a small custom server. Local certificates are for development only. Never ship them.
Optional: a custom Node server with HTTPS
You rarely need this, but if you must terminate TLS inside Node, create the server with the https module and hand requests to the Next.js handler. Load the certificate chain and private key from disk, and reload them when the certificate renews. A reverse proxy handles renewals more cleanly.
Check your result
- Load the site over
https://and confirm there are no console warnings about insecure resources. - Run the domain through a certificate checker and confirm the full chain is served.
- Follow the security headers guide to add HSTS once everything works.
- Fix any leftover
http://asset URLs. The same ideas in our mixed content guide apply to any framework.
If you are comparing free certificate sources first, read our comparison of TryFreeSSL, ZeroSSL and Let's Encrypt. Free certificates are enough for most apps. When you need organization validation, see when to upgrade to paid SSL.
Related reading: SSL for Node.js, free SSL for Squarespace and free SSL on nginx.
Frequently Asked Questions
Do I need a certificate inside my Next.js code?
No on a managed platform, which terminates TLS for you. On a VPS, Nginx terminates TLS and forwards to the Node process over localhost.
Does localhost need HTTPS?
Only when something requires it, such as secure cookies during testing. Use a local certificate for that, and never reuse it in production.
How do I confirm it worked?
Load the custom domain over https and open the certificate details. The hostname must match and the chain must be complete.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.