---
title: How can I run Next.js on localhost through HTTPS?
description: Learn how to create a self-signed certificate for use with local Next.js development.
url: /kb/guide/access-nextjs-localhost-https-certificate-self-signed
canonical_url: "https://vercel.com/kb/guide/access-nextjs-localhost-https-certificate-self-signed"
published: 2025-11-03
last_updated: 2025-11-10
authors: Lee Robinson
related:
  - /docs/security/encryption
install_vercel_plugin: npx plugins add vercel/vercel-plugin
---
<!-- docsgraph:related -->
## Related pages

> **For AI agents:** Follow these links to understand how this page connects to the rest of the Vercel ecosystem. For the full cross-link map (inbound, outbound, prerequisites, and semantic neighbors), see the .graph.md link below.

- [Working with SSL](https://vercel.com/docs/domains/working-with-ssl?from=related) — Learn how Vercel uses SSL certification to keep your site secure.
- [Custom SSL Certificates](https://vercel.com/docs/domains/custom-ssl-certificate?from=related) — By default, Vercel provides all domains with a custom SSL certificates. However, Enterprise teams can upload their own c
- [Encryption & TLS](https://vercel.com/docs/cdn-security/encryption?from=related) — Learn how Vercel encrypts data in transit and at rest.
- [Pre-Generate SSL Certificates](https://vercel.com/docs/domains/pre-generating-ssl-certs?from=related) — test
- [vercel dev](https://vercel.com/docs/cli/dev?from=related) — Learn how to replicate the Vercel deployment environment locally and test your Vercel Project before deploying using the
- [Can I deploy a locally built Next.js app to Vercel?](https://vercel.com/kb/guide/deploying-locally-built-nextjs?from=related) — Learn how to deploy a locally built Next.js application to Vercel.
- [Using Express.js with Vercel](https://vercel.com/kb/guide/using-express-with-vercel?from=related) — Learn how to use Express.js in a Serverless environment.
- [How do I resolve "ERR_SSL_PROTOCOL_ERROR" with Vercel?](https://vercel.com/kb/guide/resolve-err-ssl-protocol-error-with-vercel?from=related) — Information about how to resolve the "ERR_SSL_PROTOCOL_ERROR" error with Vercel.
- [The complete guide to authentication on Vercel](https://vercel.com/kb/guide/complete-guide-authentication-vercel?from=related) — Learn how to implement authentication in your Vercel applications. Covers NextAuth/Auth.js setup, environment variable c
- [How to Deploy a Vue.js Site with Vercel](https://vercel.com/kb/guide/deploying-vuejs-to-vercel?from=related) — Create your Vue.js app and deploy it with Vercel.

Full cross-link map for this page: [/kb/guide/access-nextjs-localhost-https-certificate-self-signed.graph.md](/kb/guide/access-nextjs-localhost-https-certificate-self-signed.graph.md)
<!-- /docsgraph:related -->


Next.js supports generating self-signed certificates for use with local development when running `next dev`. This guide will show how to use Next.js with HTTPS on `localhost`.

## Requirements

Ensure you are on the latest version of Next.js (`npm i next@latest`). If you do not already have a Next.js project created, you can [get started](https://nextjs.org/docs/getting-started/installation) with `npx create-next-app@latest`.

## Enabling HTTPS for local development

For certain features, it may be required to use HTTPS to have a secure environment on localhost. Next.js supports generated self-signed certificates for use with `next dev` as follows:

```bash
next dev --experimental-https
```

This will start the Next.js development server with HTTPS enabled on `https://localhost:3000`.

## Considerations

- These self-signed certificates should only be used for local development. In production, use properly issued certificates from trusted authorities. When deploying to Vercel, HTTPS is [automatically configured](https://vercel.com/docs/security/encryption) for your Next.js application with zero additional work.
  
- For specific testing scenarios, you might need to use real certificates and actual domains. This can be achieved by modifying the `/etc/hosts` file to map domain names to `127.0.0.1`.
  

## Conclusion

Next.js has built-in support for securely running your application on `localhost` with HTTPS. You can get started by running `next dev --experimental-https`.