ngrok: install, authtoken, ngrok http 3000, free plan and safety
What ngrok is, installing it and saving the authtoken safely, ngrok http 3000, what the free plan gives, the prices, and OAuth or basic auth in front.
ngrok gives a port on your computer or server a public HTTPS address. Install the agent, save your authtoken once with ngrok config add-authtoken, then run ngrok http 3000 and whatever listens on port 3000 answers at your dev domain, a fixed name ending in ngrok-free.dev or ngrok-free.app that ngrok picks for you. As of December 2026 the free plan gives 3 online endpoints, 1 GB of data out and 20,000 requests a month, a $5 one-time credit, and shows a warning page to browsers; Hobbyist is $10 a month and Pay-as-you-go $20. Anyone who has the address can open it, so put OAuth or basic auth in front with a traffic policy before you share it.
What ngrok does
ngrok is a small program, the agent, that opens an outbound connection to ngrok’s network and receives traffic sent to your address through it. Nothing on your machine has to accept connections from the internet: no open port, no firewall rule, no public IP. Requests to the address arrive at the agent, which passes them to the port you named on the same machine.
That makes it the quick answer to two jobs that come up when a coding agent builds something on a server. The first is a webhook: Stripe, GitHub or a chat platform has to reach the endpoint the agent just wrote, and they can only call a public HTTPS address. The second is showing a dev server to someone, or to your own phone, without deploying it. For your own eyes only, the private routes in opening a localhost app that runs on a server are usually better, because they publish nothing.
Installing it and adding the authtoken
On a Mac, with Homebrew:
brew install ngrokCopiedOn Debian or Ubuntu, ngrok’s Linux download page adds its apt repository:
curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
| sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null \
&& echo "deb https://ngrok-agent.s3.amazonaws.com bookworm main" \
| sudo tee /etc/apt/sources.list.d/ngrok.list \
&& sudo apt update \
&& sudo apt install ngrokCopiedThe same page offers a Snap and a tarball to unpack into /usr/local/bin; Windows gets a zip from the download page. The current agent is version 3.39.13 (October 22, 2026), and ngrok version prints yours. Installed through apt or Homebrew, update it there: ngrok update is only for the downloaded binary.
The agent refuses to start without an account. Sign up, copy the authtoken from the dashboard, and save it to the agent’s config file. ngrok’s own instructions put the token on the command line, which leaves it in your shell history on a server you may share with an agent and its transcripts. Type it into a hidden prompt instead; this prints a prompt, reads the token without echoing it, saves it, and clears the variable:
printf 'ngrok authtoken: '; read -rs NGROK_AUTHTOKEN; echo
ngrok config add-authtoken "$NGROK_AUTHTOKEN"
unset NGROK_AUTHTOKEN
chmod 600 ~/.config/ngrok/ngrok.ymlCopiedThat path is the Linux one; ngrok config check prints where yours is (on a Mac, ~/Library/Application Support/ngrok/ngrok.yml). The token is a secret: whoever has it can put endpoints on your account and spend its credit. It is in the config file in plain text, so a coding agent that can read your home directory can read it too. The NGROK_AUTHTOKEN environment variable also works and, per ngrok’s config docs, takes precedence over the file.
ngrok http 3000
ngrok http 3000CopiedThe agent takes over the terminal, prints the public address it forwards to http://localhost:3000, and shows requests as they arrive. Your app can stay bound to 127.0.0.1: the agent reaches it from the same machine, so there is no reason to bind the dev server to 0.0.0.0 for ngrok’s sake.
Without --url, the endpoint goes on your dev domain, which on the free plan looks like your-assigned-name.ngrok-free.dev (ngrok lists ngrok-free.app as a free accounts’ base domain too). ngrok’s domains page says it is static: it does not change when you restart the agent, and you cannot rename it. That is what makes it usable for a webhook, since the URL you register with Stripe or GitHub survives a restart. Older guides use --domain or --subdomain; both are deprecated in favour of --url.
Every request and response, bodies included, is recorded in the agent’s inspector at http://localhost:4040, which can also replay a request: useful when a webhook handler fails and you want the agent to try the same delivery again after a fix. It listens on 127.0.0.1:4040 by default; on a server, open it from your laptop through SSH forwarding rather than moving it to a public address. A coding agent on the server can read the current address without the screen:
curl -s http://127.0.0.1:4040/api/endpointsCopiedThe address is in each endpoint’s url field. The older /api/tunnels still answers but is deprecated.
If the page loads but your dev server answers with a refusal about the host, that is the dev server checking its own name, not ngrok; Vite and others refuse names they do not know, and the fix is in the localhost guide.
The free plan and the paid ones
As listed on ngrok’s pricing page and its free plan limits on December 4, 2026:
| Free | Hobbyist | Pay-as-you-go | |
|---|---|---|---|
Price | $0, with a $5 one-time credit | $10 a month, or $96 a year | $20 a month, $20 of usage credit included |
Online endpoints | 3 | 3 | Unlimited |
Domains | The dev domain only | Dev domain plus 10 ngrok-branded names | Dev domain, ngrok-branded, wildcard and your own |
Data out | 1 GB a month | 5 GB | 5 GB |
HTTP requests | 20,000 a month | 100,000 | 100,000 |
TCP addresses | Random, after card verification | 1 | 100 |
OAuth users (monthly) | 3 | 5 | 5, then $1 each |
Free endpoints have no time limit and stay up as long as the agent runs. Two things catch people out. The free plan puts an interstitial warning page in front of browser visits, which ngrok says is there to deter phishing; it applies only to GET requests from a browser, so webhooks, curl and WebSockets pass straight through, and a visitor who clicks Visit does not see it again on that domain for seven days. A program you control can skip it by sending the header ngrok-skip-browser-warning with any value. The page is not access control: anyone can click through it.
The second is that ngrok’s traffic policy, where the protections below live, is metered in traffic policy units at $0.10 per 100,000, and the free plan has no allowance of them, only the credit. The actions most worth using cost nothing: ngrok lists basic auth, OAuth and deny as free, while verify-webhook costs 1 unit and an IP restriction 10. A free policy holds up to 15 rules.
Past the included 20,000 requests, the free plan spends its credit on more, at $2 per 100,000. The pricing page says the one-time credit lasts a year, cannot pay for data out, and that when it is gone “usage stops” rather than running up a bill. On Hobbyist the same holds for its $10 a month of credit; only Pay-as-you-go bills overage. The docs do not say how a stopped endpoint answers in the meantime.
Keeping strangers out
A public address is reachable by anyone who has it, and a dev domain is a fixed name, so once it has been seen it stays valid every time you start the agent. A dev server a coding agent is building usually has no login of its own, and some expose far more than the page: debug routes, an admin screen, an API with no checks. Put one of ngrok’s own checks in front, set as a traffic policy. The old flags for this (--basic-auth, --oauth, --cidr-allow) are deprecated, and the CLI reference says to use a traffic policy instead.
Sign in with Google or GitHub
The OAuth action sends visitors through a provider’s login before they reach your app, and with GitHub, GitLab, Google, LinkedIn, Microsoft or Twitch ngrok supplies the OAuth app itself. Signing in proves only who someone is, so pair it with a rule that refuses everyone but you. Save this as policy.yml, with your own address:
on_http_request:
- actions:
- type: oauth
config:
provider: google
- expressions:
- "!(actions.ngrok.oauth.identity.email in ['you@example.com'])"
actions:
- type: deny
config:
status_code: 403Copiedngrok http 3000 --traffic-policy-file policy.ymlCopiedThis suits a browser, not a webhook: Stripe cannot sign in with Google. On the free plan, OAuth counts up to 3 different users a month.
A username and password
The basic auth action answers 401 to any request without one of up to ten username:password pairs, each password 8 to 128 characters. The pair sits in the policy file in plain text, so give the file chmod 600 and keep it out of the repository the agent commits:
on_http_request:
- actions:
- type: basic-auth
config:
credentials:
- "you:a-long-random-password"CopiedMany webhook senders cannot send credentials. For those, ngrok’s verify-webhook action checks the sender’s signature against your webhook secret and answers 403 to anything unsigned, for providers such as GitHub, Stripe and Slack; the free plan includes 500 verifications a month. Your handler should still check the signature itself.
Only from certain addresses
The restrict-ips action allows or denies by the connecting address in CIDR form, checked on the real source address and never on X-Forwarded-For. It fits a sender that publishes the addresses it calls from, or your own fixed office address:
on_tcp_connect:
- actions:
- type: restrict-ips
config:
enforce: true
allow:
- 203.0.113.10/32CopiedThat action is not the same as the “IP restrictions” line on the pricing page, which is an account-wide setting sold as a Pay-as-you-go add-on.
Keeping it running after you log out
Started in an SSH session, ngrok http stops when the session ends, and run by a coding agent it holds the agent’s terminal until killed. For a short test, start it in a tmux window and detach. For a webhook that must keep working, describe the endpoint in the config file and run the agent as a service. Add this below the lines add-authtoken wrote, leaving those as they are:
endpoints:
- name: app
url: https://
upstream:
url: 3000
traffic_policy:
on_http_request:
- actions:
- type: oauth
config:
provider: google
- expressions:
- "!(actions.ngrok.oauth.identity.email in ['you@example.com'])"
actions:
- type: deny
config:
status_code: 403Copiedurl: https:// means your dev domain. Check the file, then install and start the service, which ngrok’s service page says creates a systemd unit that starts every endpoint in the file, as ngrok start --all would:
ngrok config check
sudo ngrok service install --config "$HOME/.config/ngrok/ngrok.yml"
sudo ngrok service startCopiedThe service reads the config where it was when you installed it, so do not move the file afterwards. Errors go to syslog. ngrok does not say which user the service runs as, and a systemd system service runs as root unless its unit names another user; if you would rather it ran as you, a systemd user unit that runs ngrok start --all does the same, provided lingering is on so it survives logout and reboot.
ngrok alternatives
Three others do the same job in different ways.
- Cloudflare quick tunnel:
cloudflared tunnel --url http://localhost:3000needs no account, but thetrycloudflare.comname changes every run, which rules it out for a registered webhook. Cloudflare says it is for testing and development, with 200 requests in flight and no server-sent events, and points to a named Cloudflare Tunnel for a stable hostname. Tailscale against Cloudflare Tunnel compares that with Tailscale’s routes. - Tailscale Funnel:
tailscale funnel 3000publishes a port at the machine’sts.netname, on every Tailscale plan, and Tailscale Serve does the same for your own devices only. Both are in the Serve and Funnel guide. - An SSH reverse tunnel:
ssh -Rputs a local port on another machine you can SSH into. It costs nothing if you already have a server with a public address, but sshd binds the forwarded port to that server’s loopback unless itsGatewayPortssetting says otherwise, and TLS and any login are yours to add.