Development

How to Install and Use Ngrok on Windows

Captain Salem 3 min read

How to Install and Use Ngrok on Windows

ngrok is a cross-platform application that allows you to expose a local development server to the internet. It provides a real-time web UI where you can introspect all HTTP traffic running over your tunnels for inspection and replay.

In this tutorial, we will learn how to install and use the ngrok tool on Windows.

NOTE: In this tutorial, we tested the installation and working of ngrok on Windows 11 using XAMPP HTTP Server running on port 80. However, this tutorial will work on Windows version any server running on any port.

Features of Ngrok

Ngrok provided exceptional features such as:

Encryption Instant domains
Automatic certificates and an A+ SSL report card with no config. Use a ngrok domain with no setup or bring your own domain.
Identity Load balancing
Protect services with OAuth, SAML and OIDC. Route traffic to multiple backends for scale and fault tolerance.
Runs everywhere Observability
One executable, no dependencies. Any OS, any CPU architecture. Log all traffic and account activity.
Any protocol Zero Trust
Native support for HTTP, TLS, and any TCP based protocol. Add SSO, Mutual TLS, IP Policy, and webhook signature verification.

Let us now learn how to install ngrok on your Windows system.

Method 1 - Using Chocolatey

The first and recommended method of installing ngrok on your system is using chocolatey.

Chocolatey is a package manager for Windows. It is designed to simplify the process of managing software on the Windows operating system in a way that’s consistent and understandable.

if you do not have chocolatey installed, you can use the tutorial below:

https://www.geekbits.io/how-to-install-chocolatey-on-windows-11/

Once you have chocolatey installed, run the command below to install ngrok.

choco install ngrok

The command above should download and install ngrok on your machine.

Output:

Chocolatey v2.0.0
Installing the following packages:
ngrok
By installing, you accept licenses for the packages.
Progress: Downloading ngrok 3.3.1... 100%

ngrok v3.3.1 [Approved]
ngrok package files install completed. Performing other installation steps.
The package ngrok wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): A

File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded.
Error - hashes do not match. Actual value was 'B301BA4EEDF25B3E96D3E774FAB0DBB0D4427E628AF746D18E9E2B8AC137FF7A'.
Downloading ngrok 64 bit
  from 'https://bin.equinox.io/a/cJk8dzafvmN/ngrok-v3-3.3.1-windows-amd64.zip'
Progress: 100% - Completed download of ...\Temp\chocolatey\ngrok\3.3.1\ngrok-v3-3.3.1-windows-amd64.zip (8.62 MB).
Download of ngrok-v3-3.3.1-windows-amd64.zip (8.62 MB) completed.
Hashes match.
Extracting ...\AppData\Local\Temp\chocolatey\ngrok\3.3.1\ngrok-v3-3.3.1-windows-amd64.zip to C:\ProgramData\chocolatey\lib\ngrok\tools...
C:\ProgramData\chocolatey\lib\ngrok\tools
 ShimGen has successfully created a shim for ngrok.exe

Method 2 - Using Scoop

You can also use scoop to install and configure ngrok on your machine. If you do not have scoop installed, you can use the tutorial in the link below:

https://www.geekbits.io/how-to-install-scoop-on-windows/

Once installed, start by updating scoop and the installed packages with the command:

scoop update

Output:

Updating Scoop...
Updating 'main' bucket...
 * ccb793ebf pulumi: Update to version 3.72.2                       
 * be375fed9 dirhash: Update to version 1.24.0
 ---

Finally, run the command below to install ngrok:

scoop install ngrok

The command will download and configure scoop on your system.

Method 3 - Manual Install

You can also perform a manual install by downloading the ngrok zip from the official site. Once downloaded, extract the zip to a specific directory and add it to the system path.

Configuring Ngrok

Once you have ngrok installed, you need to configure it. Let us discuss how you can do this.

Adding Auth Token

The first step is to add the authentication token for your ngrok account. You can do this by signing up for Ngrok in the link below:

https://dashboard.ngrok.com/signup

Once signed up, copy the authentication token and run the command:

ngrok config add-authtoken 56BLu0Bk2y4cXSK...

Where the last part represent your auth token.

You should get an output as shown:

Authtoken saved to configuration file: C:\Users\...\AppData\Local/ngrok/ngrok.yml

Once configured, you can go ahead and start a tunnel to your target port as shown in the example below:

Start a HTTP Tunnel

For example, suppose we have Apache Web Server running on port 80 on our Windows system and we wish to expose that server to the internet. We can use ngrok with the command below:

ngrok http 80

The command above should start a HTTP tunnel forwarding to your local port 80. You should get a unique address which you can share with anyone in the world to access the web server hosted on your local machine.

image-20230618062032212
image-20230618062032212

Once completed, you can terminate the tunnel by pressing CTRL + C.

Conclusion

In this tutorial, we learned how to install and configure ngrok on Windows to expose any service running on our local machine to the world using tunneling and encryption.

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.