Appendix D Installing and using ngrok
This appendix explains a quick way to put in-progress web applications on the internet before they are fully production-ready. It introduces ngrok as a simple tunneling tool that exposes a locally running web app to the outside world, making it easy to share work with teammates or testers and to validate behavior in a real internet context without a full deployment pipeline.
Installation is presented as straightforward: follow the official guidance to get ngrok running on your machine. The emphasis is on accessibility and speed—ngrok’s setup process is designed to be simple so you can rapidly move from local-only development to an externally reachable endpoint suitable for demos and iterative feedback.
After installation, you verify that everything is set up correctly by checking the version from the command line using ngrok --version, which should print a version string (for example, “ngrok version 3.1.0”). With installation confirmed, you can use ngrok to securely tunnel your local service to a public URL, enabling immediate sharing and testing while you continue learning the more robust, production-focused workflows introduced elsewhere in the book.
D.3 Running ngrok
Now that we have verified ngrok is installed, let’s run it:
ngrok http 3011
The command breaks down like this:
- ngrok http—Start an ngrok with an HTTP tunnel.
- 3011—The port we want to expose, which is exactly mapped to http://localhost:3011.
This will output something like the following:
stdout
Session Status online
Account Justin Mitchel (Plan: Free)
Version 3.1.0
Region United States (us)
Latency 65ms
Web Interface http://127.0.0.1:4040
Forwarding https://1f69-192-63-174-214.ngrok.io -> http://localhost:3011
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
Options to Stop/Cancel the running ngrok tunnel are as follows:
- Exit the command line/terminal window (easiest).
- Use CTRL+C in the terminal where the program is running (recommended).
- Use kill -9 <PID> where <PID> is the process ID of the ngrok tunnel instance (advanced).
FAQ
What is ngrok and why would I use it?
ngrok creates a secure public URL that tunnels to an app running on your local machine, so you can share and test local web apps on the internet for demos, feedback, or webhook development.How do I install ngrok?
Go to https://ngrok.com/download and follow the platform-specific steps provided there. The site has a short, guided setup that walks you through installation.How can I verify that ngrok installed correctly?
Open a terminal and runngrok --version. If installation succeeded, it will print the installed version.Do I need an ngrok account or authtoken?
You’ll typically be prompted to connect your account using an authtoken during setup. Follow the prompts or the download page instructions to add your authtoken for full functionality.How do I expose a local web app to the internet?
Start your app locally (for example on port 3000), then runngrok http 3000. ngrok will display a public forwarding URL you can share.Is ngrok intended for production use?
It’s primarily for development, testing, and sharing in-progress work. For real production deployments, use proper hosting, ingress, and security hardening.What platforms does ngrok support?
ngrok provides installers and binaries for major platforms (Windows, macOS, and Linux). Use the download page to pick the build for your OS and CPU.How do I stop an ngrok tunnel?
PressCtrl+C in the terminal where ngrok is running. The public URL will stop working immediately.What should I check if the public URL doesn’t work?
Confirm your app is running locally and reachable athttp://localhost:<port>, verify you used the correct port in ngrok http <port>, and ensure no firewall or VPN is blocking the connection.
Road to Kubernetes ebook for free