
What Is Ngrok? How It Works, Uses, Security Risks, and Alternatives
What is ngrok? Ngrok is a tool that creates a secure tunnel from a public internet address to a service running on your local computer. In plain terms, it gives your localhost a public URL, so anyone on the internet can reach a website, app, or API that normally only exists on your own machine. Developers use it to test, demo, and share local work without deploying it to a server first.
For example, if you are building a website on your laptop at http://localhost:3000, nobody outside your home network can normally open it. Start ngrok, and it gives you a public address such as https://a1b2c3d4.ngrok-free.app that forwards traffic to that local port. When you stop ngrok, the tunnel closes and the address stops working. That combination of speed and temporary access is why ngrok has become a standard part of modern web development.
What Is Ngrok?
Ngrok is a cross-platform tunnelling service and command-line tool. It runs a small agent on your computer, connects to ngrok’s cloud, and opens a secure tunnel between the two. The cloud side listens on a public URL, and the agent forwards every request it receives to your local service, then sends the response back. You do not need to change router settings, open firewall ports, or buy a server to do this.
The name comes from the idea of exposing, or “grokking”, a local service to the wider internet in a controlled way. Ngrok was first released for developers who needed to show work in progress, test payment webhooks, and debug APIs. Today it is also used for remote access to local devices, Internet of Things projects, and internal tools that need a safe, temporary public endpoint.
Ngrok is not a web host, a virtual private network, or a content delivery network. It does not store your website permanently, and it does not replace deployment. It is a bridge: your code stays on your machine, while ngrok provides the public doorway to it.
How Does Ngrok Work?
Ngrok works through a simple client-and-cloud model. Understanding the flow makes it much easier to use safely.
- You start a local service. This might be a website on port 3000, an API on port 8000, or a database admin panel on port 8080. It listens only on your computer.
- You start ngrok for that port. For example, you run
ngrok http 3000. The ngrok agent on your machine connects outward to ngrok’s cloud over an encrypted connection. - Ngrok assigns a public URL. On the free plan this is a random subdomain, such as
https://random-name.ngrok-free.app. Paid plans allow fixed or custom domains. - Visitors use the public URL. Their requests go to ngrok’s cloud, travel through the tunnel, and arrive at your local service.
- Your service replies. The response travels back through the same tunnel to the visitor. Ngrok also shows a live log of requests, so you can inspect traffic in real time.
Because the agent connects outward, it usually works even behind a home router or a corporate firewall, where incoming connections would normally be blocked. This is similar in spirit to the way secure tunnels protect older protocols, although ngrok is designed for HTTP, HTTPS, and TCP traffic rather than for encrypting a single legacy service.
What is a tunnel in ngrok?
A tunnel is the encrypted path between ngrok’s public endpoint and your computer. One tunnel serves one local port. You can run several tunnels at once for different services, for example a website on one tunnel and an API on another. Each tunnel has its own public URL, and you can stop any tunnel without affecting the others.
What Is Ngrok Used For?
Ngrok is useful whenever a local service needs to be reachable from outside your network for a short time. Common uses include:
- Testing webhooks. Payment providers, messaging apps, and other services send webhook events to a public URL. Ngrok lets you receive those events on your laptop while you develop, and inspect each request and its payload.
- Sharing work in progress. Show a client, designer, or teammate a website before it is deployed, without setting up staging hosting.
- Testing on real phones and devices. Open the ngrok URL on a phone, tablet, or another computer to test responsive design and device behaviour.
- Local API development. Let a mobile app, a partner system, or a third-party service call an API that is still running on your machine.
- Remote access and demos. Demonstrate an internal dashboard or prototype in a meeting, or reach a home server while travelling, without exposing it permanently.
- Internet of Things and home labs. Reach a Raspberry Pi, a home automation panel, or a local camera system through a controlled tunnel instead of opening router ports.
In each case the key benefit is the same: no deployment, no DNS changes, and no router configuration. You get a working public link in seconds.
Ngrok vs Port Forwarding, VPN, and Other Options
Ngrok is often compared with port forwarding and VPNs, but the three solve different problems. A VPN encrypts your own connection and can hide your IP address, which is a different job from exposing a local service. If you are unsure how that works, read our guide on whether a VPN changes your IP address.
| Option | What it does | Best for | Drawbacks |
|---|---|---|---|
| Ngrok | Public URL tunnels to localhost | Quick demos, webhooks, testing | Free URLs change; trust a third party |
| Port forwarding | Router sends internet traffic to a device | Permanent home servers | Exposes a port; router setup needed |
| VPN | Encrypts your connection; private network access | Privacy and remote office access | Does not give a public URL for localhost |
| Cloud hosting | Runs your app on a public server | Production websites | Slower to set up; ongoing cost |
For production, host your app properly. For development and testing, ngrok is usually faster and safer than opening ports on your router. For site-to-site or office connectivity, a dedicated VPN technology such as IPsec is the right tool, not a development tunnel.
How to Install and Use Ngrok
Getting started takes only a few minutes. The exact steps are the same on Windows, macOS, and Linux.
Step 1: Create an account and get an auth token
Download ngrok from its official website and create a free account. Your dashboard gives you a personal auth token, a long string that links the agent on your computer to your account. Keep it private, just like a password. If you share it, someone else could create tunnels under your account.
Step 2: Install ngrok
On Windows, download the installer or use a package manager. On macOS, you can use Homebrew with brew install ngrok. On Linux, download the archive, extract it, and move the binary to a folder in your path. Run ngrok version to confirm it installed correctly.
Step 3: Connect your account
Run ngrok config add-authtoken YOUR_TOKEN, replacing YOUR_TOKEN with the token from your dashboard. You only need to do this once per computer.
Step 4: Start your local service, then start a tunnel
Start your website or API first, and note its port. Then run ngrok http 3000 if it uses port 3000. Ngrok prints a public URL and a local inspection address, usually http://127.0.0.1:4040.
Step 5: Share the URL and inspect traffic
Share the public URL with the people or services that need it. Open the inspection page at port 4040 to see each request, its headers, and its response, and to replay requests while you debug. When you are finished, press Ctrl+C in the terminal to stop ngrok and close the tunnel.
You can also expose TCP services with ngrok tcp 22 for SSH, or use a configuration file to define several tunnels, custom subdomains, and request rules in one place.
Is Ngrok Safe?
Ngrok itself uses encrypted connections, but safety depends on what you expose and how you configure it. A tunnel makes a local service public, so anything that service allows becomes reachable by anyone who finds the URL. That is powerful, and it is also the main risk.
The most common problems are: exposing a development server that has no login, debug mode, or admin panel; sharing a tunnel URL in a public place where strangers can use it; leaving a tunnel running for days when you only needed it for an hour; and trusting a random ngrok URL sent by someone else, because attackers have used ngrok addresses in phishing pages and malware delivery.
Follow these rules to use ngrok safely: expose only the service you need, and only for as long as you need it; add authentication to the local app or use ngrok’s built-in basic authentication and IP restrictions on paid plans; never expose a database, file share, or admin panel without a strong password; use HTTPS on your local service where possible; stop the tunnel as soon as you finish; and never log in to an important account through a ngrok link you did not create yourself. If a link looks suspicious, close it and contact the sender through a separate channel.
Ngrok Pricing: Free vs Paid
Ngrok has a free tier and several paid tiers. Prices and limits change over time, so check the official pricing page before you choose, but the structure is stable.
| Feature | Free | Paid plans |
|---|---|---|
| Public URL | Random subdomain that changes | Fixed or custom domains |
| Simultaneous tunnels | Limited | More tunnels and connections |
| Authentication and IP rules | Basic | OAuth, IP restrictions, and more |
| Traffic inspection | Yes, in the local dashboard | Longer history and team features |
| Best for | Learning and occasional testing | Teams, webhooks, and regular use |
For most learners, the free plan is enough. If you need a stable URL for a webhook provider, a custom domain, or team controls, a paid plan is worth it, because a changing free URL means updating your webhook settings every time you restart ngrok.
Ngrok Alternatives
Ngrok is popular, but it is not the only tunnelling tool. Cloudflare Tunnel is a strong alternative for permanent, secure access and works well with Cloudflare’s access controls. Localtunnel is a simple, free, open-source option for quick sharing. Serveo and localhost.run work over SSH and need no installation beyond an SSH client. Zrok and Bore are newer open-source options for self-hosting your own tunnel server. Choose based on whether you need a quick temporary link, a stable production tunnel, or full control over your own infrastructure.
Common Ngrok Errors and How to Fix Them
“Failed to start tunnel” or “port already in use”: another service or an old ngrok process is using that port. Stop the other process or choose a different port.
“Authentication failed”: your auth token is missing or wrong. Re-add it with ngrok config add-authtoken and check for extra spaces.
“Too many connections” or rate limits: the free plan has connection limits. Close unused tunnels, reduce traffic, or upgrade.
“ERR_NGROK_3200” or a warning page: the free plan shows a browser warning page before the site loads. Click through it for testing, or use a paid plan to remove it.
Webhook provider rejects the URL: some providers require a stable URL or a verified domain. Use a paid fixed domain, or register the new URL in the provider’s dashboard after each restart.
Frequently Asked Questions About Ngrok
What is ngrok used for?
Ngrok is mainly used to expose a local website, API, or service to the internet for testing, demos, and webhooks. Developers use it to share work in progress, test on real devices, and receive webhook events on a laptop without deploying to a server.
Is ngrok free?
Yes, ngrok has a free plan with a random public URL, limited tunnels, and basic features. Paid plans add fixed and custom domains, more tunnels, authentication controls, and team features. Check the official pricing page for current limits.
Is ngrok safe to use?
Ngrok uses encrypted tunnels, but it makes your local service public, so it is only as safe as the service you expose. Add authentication, expose only what you need, keep tunnels short-lived, and never trust a ngrok link from an unknown sender.
Does ngrok expose my IP address?
Visitors see ngrok’s public address, not your home IP address directly, but ngrok itself knows your connection. Your local service’s logs will show traffic coming through the tunnel. Do not treat ngrok as a privacy or anonymity tool.
What is the difference between ngrok and a VPN?
A VPN encrypts your internet connection and gives you private access to a network, while ngrok gives a local service a public URL. A VPN hides or changes how you connect out; ngrok lets others connect in to a specific local port. They solve opposite problems and are often used together.
Conclusion
Ngrok is a fast, practical way to give a local project a public address. It is ideal for webhook testing, demos, and sharing work before deployment, and it removes the need for router changes or temporary hosting. Use it with care: keep tunnels short, protect the services you expose, and move to proper hosting when a project goes live. Used that way, ngrok saves hours of setup and makes local development feel like the real internet, because, for the length of the tunnel, it is.


