How to Install and Use ngrok on macOS (Homebrew) and Windows
Ngrok is a powerful tool that lets you expose your local server (running on your laptop, ESP32, or Raspberry Pi) to the internet using a secure tunnel. This is super useful for testing webhooks, sharing your development server with others, or accessing IoT devices remotely.
In this guide, I’ll show you how to install ngrok on macOS (with Homebrew) and Windows, and run your first tunnel.
🔹 1. Install ngrok on macOS with Homebrew
Step 1: Install Homebrew (if not already installed)
Open Terminal and paste:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Once installed, run:
brew -v
to confirm.
Step 2: Install ngrok
brew install --cask ngrok
Step 3: Authenticate ngrok
Create a free account at ngrok.com.
Copy your authtoken from the dashboard, then run:
ngrok config add-authtoken YOUR_AUTHTOKEN_HERE
Step 4: Start a tunnel
If your local app is running on port 8080:
ngrok http 8080
You’ll see a forwarding URL like:
Forwarding https://abcd1234.ngrok.io -> http://localhost:8080
🔹 2. Install ngrok on Windows
Step 1: Download ngrok
-
Go to the ngrok download page.
-
Download the Windows .zip version.
-
Extract it to
C:\ngrok\
(or another folder of your choice).
Step 2: Add ngrok to PATH (optional but useful)
-
Press
Win + R
, typesysdm.cpl
, and hit Enter. -
Go to Advanced > Environment Variables.
-
Under System variables, find
Path
→ click Edit → New. -
Add
C:\ngrok\
→ Save.
Now you can runngrok
from anywhere in Command Prompt.
Step 3: Authenticate ngrok
Open Command Prompt and run:
ngrok config add-authtoken YOUR_AUTHTOKEN_HERE
Step 4: Start a tunnel
If your local app runs on port 3000:
ngrok http 3000
Ngrok will give you a public HTTPS link.
🔹 3. Useful ngrok Commands
-
Start tunnel on port 80:
ngrok http 80
-
Tunnel a different IP and port (e.g., ESP32 on LAN):
ngrok http 192.168.1.50:80
-
View request logs:
http://127.0.0.1:4040
✅ Wrapping Up
That’s it! You’ve now installed ngrok on macOS with Homebrew and Windows. With just a single command, you can securely share your local server with the world.
Ngrok is free for basic use, but upgrading unlocks reserved subdomains, custom domains, and more.
Post a Comment