Install and use Ngrok on Ubuntu (Window WSL) for NextJS

Ngrok NextJS Ubuntu Window WSL

4 minute read

Ngrok is a tool that creates secure tunnels to expose your local server to the internet. It allows you to share localhost applications, such as web servers or APIs, with a public URL

Key Features:

  1. Public URL: Generates a unique URL (HTTP/HTTPS) to access your localhost.
  2. Secure Tunnel: Provides end-to-end encrypted connections.
  3. Use Cases: Testing webhooks, sharing development work, or debugging APIs.
  4. Cross-Platform: Works on Windows, macOS, and Linux.

1. Download Ngrok from this link Ngrok download

Ensure your system is updated:

$ sudo apt update && sudo apt upgrade -y

Download Ngrok:

$ get https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz

You can check the file was downloaded on your machine:

$ ls

2. Unzip the downloaded file:

$ tar -xvzf ngrok-v3-stable-linux-amd64.tgz

I will have the #ngrok file on current folder

$ ls

3. Move Ngrok to a Global Path

$ sudo mv ngrok /usr/local/bin/

4. Verify Installation

$ ngrok version

if the version is shown, your installing was success.

5. Authenticate Your Ngrok

Before we can use Ngrok, we need to authenticate with Ngrok service.

Go to the Ngrok'website, and sign in (if do not have account, please sign up), after that, you go to https://ngrok.com/get-started/your-authtoken to get your token.

Copy the token and pass into thsi command:

$ ngrok config add-authtoken <your-auth-token>

Now, you’re authenticated and ready to use Ngrok! 🎉

6. Run Ngrok

To expose your local development server:

  1. Start your local server (e.g., running on localhost:3000).
  2. Open a terminal or command prompt and run:
$ ngrok http 3000

After run this command, the terminal will shown some info, in this we have Forwarding info, the public URL is https://abcxyz.ngrok-free.app.

Use this URL to access your local server from the internet.