Overview
Perfai’s Vision, Security, and Fix agents run in Perfai’s cloud — they open a cloud browser and navigate to your app’s URL over the public internet. If your app only exists onlocalhost, inside a corporate VPN, on a private staging network, or behind a firewall with no public DNS entry, Perfai’s agents can’t reach it directly.
ngrok solves this with a reverse tunnel: a lightweight agent you run next to your app opens an outbound connection to ngrok’s edge, which then hands you a public HTTPS URL that forwards every request straight back to your local or internal app. Paste that public URL into Perfai like you would any other app URL, and testing proceeds exactly as normal — your app never needs to be deployed anywhere public.
When you need this
Local development
localhost and hasn’t been deployed to a staging or production environment yet.Private/internal networks
Firewalled environments
Pre-launch products
Install ngrok
Pick the install method for your platform.Install the ngrok agent
PATH.Confirm it’s installed:Create a free ngrok account
Connect your agent with an authtoken
Start a tunnel to your app
Run ngrok against the port your app is already listening on. For an app running onlocalhost:3000:
Point Perfai at the tunnel
Once the tunnel is up, use the ngrok URL exactly like any other app URL.Copy the Forwarding URL
https:// forwarding address, e.g. https://a1b2-203-0-113-42.ngrok-free.app.Add it as a new app
Let the agents run
Keeping the tunnel stable for continuous testing
Perfai re-maps and re-tests apps on an ongoing schedule (see Managing an app). A tunnel that disappears or changes URL between scans breaks that schedule, so treat the tunnel as part of your app’s uptime for as long as you want continuous coverage.The free ngrok URL changes every time I restart the tunnel
The free ngrok URL changes every time I restart the tunnel
ngrok http, you get a different .ngrok-free.app address, which breaks Perfai’s stored URL for that app.Fix it with a static domain — ngrok’s free plan includes one reserved domain that stays the same across restarts. Claim one from dashboard.ngrok.com/domains, then start the tunnel with:Can ngrok run unattended, e.g. for nightly scans?
Can ngrok run unattended, e.g. for nightly scans?
systemd or a process manager like pm2; on macOS, a launchd agent or a terminal multiplexer (tmux/screen) works well. The command is the same either way: ngrok http --url=your-reserved-name.ngrok-free.app 3000.Combine this with a static domain so the URL Perfai has on file never goes stale.My app's URL changed — how do I update it in Perfai?
My app's URL changed — how do I update it in Perfai?
Securing the tunnel
Exposing an internal app publicly, even temporarily, widens its attack surface beyond Perfai’s own agents. Apply these restrictions so only Perfai — and you — can reach it:- Restrict by IP where possible. ngrok’s traffic policy lets you allow only specific source IPs on a tunnel. This is the strongest option if your network setup supports it.
- Add basic auth as a lightweight gate. Perfai’s cloud browser doesn’t support interactive auth prompts, so don’t combine this with Perfai testing unless you’re only using the tunnel for manual access. For agent-driven scans, prefer IP restriction or simply limiting the tunnel’s lifetime instead.
- Only run the tunnel while you need it. Stop
ngrok httpwhen a scan finishes if you don’t need continuous coverage — a tunnel that isn’t running can’t be reached by anyone. - Don’t tunnel into production. Point ngrok at a staging or test environment with non-production data and test accounts, consistent with how Perfai testing works generally — see Bring your own accounts.
Frequently asked questions
Do I need a paid ngrok plan?
Do I need a paid ngrok plan?
Does Perfai support other tunneling tools, like Cloudflare Tunnel or localtunnel?
Does Perfai support other tunneling tools, like Cloudflare Tunnel or localtunnel?
Will Perfai's traffic show up in my ngrok dashboard?
Will Perfai's traffic show up in my ngrok dashboard?
http://127.0.0.1:4040 while a tunnel is running, or the dashboard at dashboard.ngrok.com) logs every request passing through the tunnel, including Perfai’s Vision and Security Agent traffic — useful for confirming the agents are actually reaching your app.Testing stalled partway through — what should I check first?
Testing stalled partway through — what should I check first?
ngrok http process is still running, confirm your local app is still up (the tunnel has nothing to forward to otherwise), and confirm the URL on file in Perfai’s Advanced Options still matches the current ngrok forwarding address.
