Skip to Content
HeyBug docs
Guides

Test an app running on localhost

Use this guide when the app you want to test runs on your own machine, for example at `http://localhost:3000`.

Use this guide when the app you want to test runs on your own machine, for example at http://localhost:3000. How you reach it depends on where HeyBug runs.

Where HeyBug runsHow runs reach your appWhat you do
HostedThrough a tunnel that you open from your machineRun heybug tunnel start

Your app always stays on your machine. Hosted runs use a browser in our cloud, so they reach your app only through the tunnel.

  1. Start the HeyBug server with HEYBUG_ALLOW_PRIVATE_TARGETS=1. It is off by default because it lets runs reach private addresses. Set it only on a server you control.
  2. Start your app, for example on port 3000.
  3. Start a run against the local address:
heybug runs start --project <projectId> --target-url http://localhost:3000

Hosted: open a tunnel

  1. Start your app on a local port, for example 3000.
  2. Open a tunnel to that port and leave the command running:
heybug tunnel start --port 3000 --ttl 3600

--ttl sets how long the tunnel stays open, in seconds, from 60 to 3600. The command prints a public address that ends in /t/<id>/.

  1. In a second terminal, run the tests against that public address:
heybug runs start --project <projectId> --target-url https://<public-address>/t/<id>/

HeyBug adds the tunnel key to runs that target the tunnel, so you don't need to set it yourself.

  1. Press Ctrl-C in the tunnel terminal when you finish. The tunnel closes, and its address stops working.

To see or stop tunnels:

heybug tunnel list --output json
heybug tunnel stop <id>

From an AI assistant

The heybug_run MCP tool takes a url. Pass the address the run should use:

{ "name": "heybug_run", "arguments": { "url": "http://localhost:3000" } }

On hosted HeyBug, open a tunnel first and pass its public address as url. See MCP for how to connect a client.

Security

  • The tunnel forwards only to 127.0.0.1 on the port you chose. It does not expose other ports on your machine.
  • A request to the public address without the tunnel key is refused. The key goes only to runs in your workspace.
  • A tunnel stops working when you press Ctrl-C, when its time limit ends, or when you run heybug tunnel stop.
  • Use tunnels while you build and test. Don't leave one open between sessions.

When it fails

  • "That address points to a private network, which hosted HeyBug cannot reach." You used localhost on hosted HeyBug. Open a tunnel and use its public address instead.
  • "The tunnel has ended (expired or stopped)." The tunnel closed. Start heybug tunnel start again. It issues a new address, so update --target-url.
  • "… Is heybug tunnel start running?" The run reached the tunnel, but nothing answered on your machine. Keep the tunnel command running while the run is active.
  • "The local app on port N did not answer." Your app is not running, or it is on a different port. Start it and check the port number you passed to --port.
  • "this workspace already has N open tunnels; stop one first." Run heybug tunnel list, then heybug tunnel stop <id> for the one you no longer need.
  • Other errors. See Troubleshooting.

On this page