Skip to content

Tunnel Agent — Test Localhost & Internal Apps

The Tunnel Agent lets you test applications that aren’t publicly accessible — localhost development servers, internal staging environments, and apps behind corporate firewalls. It creates a tunnel between your machine and InsightJet’s cloud testing infrastructure.

InsightJet runs Playwright browsers in the cloud. Without the tunnel agent, those browsers can only reach public URLs. The tunnel agent solves this by routing cloud browser traffic through your local machine:

InsightJet Cloud (Playwright) → Tunnel → Your Machine → localhost:3000

This means you can:

  • Test during development — analyze and discover components on localhost
  • Test staging environments — reach internal servers behind firewalls
  • Test private networks — access intranet tools and internal dashboards
  • Test before deployment — catch UI issues before code goes public

The tunnel agent is an npm package you install globally:

Terminal window
npm install -g insightjet

  1. Log in

    Run the login command — it opens your browser to authenticate:

    Terminal window
    insightjet login

    Your browser opens to InsightJet’s login page. After authenticating, the token is saved locally to ~/.insightjet/config.json.

  2. Start the agent

    Terminal window
    insightjet start --allow localhost:3000

    --allow is required: it names the addresses (host and port) InsightJet may reach. The agent connects to InsightJet’s crawler gateway over a WebSocket and is ready to forward requests.

  3. Learn your local app

    In InsightJet, click Learn and enter your local address with its scheme, exactly as your app is served: http://localhost:3000 for a plain dev server, https://localhost:3000 for one served over https (a self-signed certificate is fine). InsightJet keeps the address as you typed it. During setup, choose Runs on your computer (localhost)? Connect it with our tunnel on the Add your app step; it shows the same commands. A local address (localhost, *.local, a private network address) is always crawled through your tunnel, and a public one never is. If the agent is not running, InsightJet says so and starts nothing.

    Settings → Tunnel shows the same steps and when your tunnel last started or reconnected. The terminal running insightjet start shows whether it is connected now.

The first pages of a local crawl can take a minute or two to appear, because the crawler’s browser starts up first.


CommandDescription
insightjet loginAuthenticate via browser and save credentials
insightjet start --allow localhost:3000 localhost:8080Start the tunnel; it forwards only to the listed addresses (--allow is required)
insightjet statusShow who is signed in and which InsightJet server the agent uses
insightjet logoutClear saved credentials

Without installing, npx insightjet login and npx insightjet start --allow localhost:3000 work the same way. Run the tunnel on one computer at a time: InsightJet sends your crawls through the one that started last.


The agent forwards nothing until you name what it may reach. --allow is required and takes one or more addresses, each with its port:

Terminal window
insightjet start --allow localhost:3000 localhost:8080 192.168.1.50:443

Only requests to the listed host:port combinations will be forwarded. All others are rejected, and an address without a port is refused when the agent starts.


Tunnel tokens are in Settings → Keys → Tunnel tokens:

  • New tunnel token — create a token with a name (e.g., “MacBook Pro”). It is shown once and works for 90 days.
  • Revoke — invalidate a token immediately

You can have multiple tokens for different machines (e.g., work laptop, home desktop).

Settings → Tunnel shows when your agent last started or reconnected. Whether it is connected now is shown in the terminal where it runs.


The tunnel is a reverse proxy that ends at InsightJet’s crawler gateway:

  1. Ticket — the agent asks InsightJet for a short-lived ticket with your token (a new one for every connection)

  2. Agent connects — the agent opens a WebSocket to the crawler gateway and shows the ticket; the gateway refuses a connection without a valid one

  3. Crawl routed — when you crawl a local address, InsightJet tells the crawler to use your tunnel; public addresses never go through it

  4. Traffic flows — browser requests travel through the gateway → WebSocket → your agent → local TCP connection → your app

  5. Bidirectional streaming — responses flow back through the same path. Each connection gets a unique stream ID for multiplexing


FeatureDetails
Encrypted transportThe ticket request to InsightJet uses HTTPS and the connection to the crawler’s gateway uses WSS; the agent refuses an address that is not encrypted. Each ticket lives five minutes and works for your tunnel only
JWT authenticationTokens are signed, expire in 90 days, and can be revoked instantly; your token is sent only to InsightJet, never to the gateway
Host allowlistRequired: only the exact host:port addresses you list can be reached
Stream isolationEach browser connection gets a unique stream ID
No inbound portsYour machine doesn’t need any open ports — the agent initiates the outbound connection — and no port is opened on insightjet.ai: the tunnel ends at the crawler’s gateway

IssueSolution
Agent won’t connectCheck your internet connection and that wss://api.insightjet.ai is not blocked by your firewall, then check the terminal running insightjet start says “Connected to InsightJet’s crawler gateway”
Token expiredRun insightjet login to re-authenticate (tokens expire after 90 days)
A crawl can’t reach localhostVerify your local app is running, and check the terminal running insightjet start says “Connected to InsightJet’s crawler gateway”
A local crawl fails right awayCheck that the address starts with the scheme your app really uses (http:// or https://), and that the terminal running insightjet start says it is connected
Connection dropsThe agent reconnects by itself with exponential backoff, also after a network drop or a sleeping laptop, and asks for a fresh ticket each time. If it keeps dropping, check your network stability. Run npm install -g insightjet@latest to get the newest version
Port conflictsThe agent doesn’t listen on local ports — it initiates outbound connections only