> For the complete documentation index, see [llms.txt](https://docs.bugbug.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bugbug.io/running-tests/test-your-local-build-or-protected-web-page-using-ngrok.md). Agents can also search and read this documentation through its [MCP server](https://docs.bugbug.io/~gitbook/mcp).

# Test your local build or protected web page using ngrok

Learn how to test your local build or protected web page using ngrok. BugBug provides step-by-step instructions and tips for seamless testing. Start testing for free!

You can use BugBug to test your local build or a private site with restricted access.

## Do you need a tunnel?

* **Local runs** happen in your own browser, so they can open `localhost` and any site your computer can reach. You don't need a tunnel to [run tests locally](https://docs.bugbug.io/running-tests/test-in-your-browser.md) or to record them.
* **Cloud runs** and [schedules](https://docs.bugbug.io/running-tests/schedules.md) happen on BugBug's servers, which can't reach your computer or your private network.

For a staging or internal site behind a VPN or a firewall, the recommended option is to allow the IP address of the Cloud Proxy selected in your project settings. See [VPN or a Firewall](https://docs.bugbug.io/troubleshooting/vpn-or-a-firewall.md).

If you can't do that, or you want to run cloud tests against a build on your own computer, publish it with a tunnelling tool such as ngrok, as described below.

{% hint style="info" %}
ngrok is **not** part of BugBug. It's a third-party tool that exposes your website at a public URL. Before you decide to use it, you may want to contact your network administrator.
{% endhint %}

ngrok opens a secure tunnel that makes your local port available from the internet. When your local build or protected page is available at the public URL created by ngrok, BugBug can open it in the cloud, run tests and help you record steps.

## Set up ngrok

1. Sign up on the ngrok website and download the ngrok agent.
2. Copy your auth token from the ngrok dashboard.

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2F77YucDF70YsYnacOGNSE%2Fng%20auth%20token.png?alt=media&amp;token=0804357e-e579-4bb4-aac2-2cb1ab26db16" alt=""><figcaption></figcaption></figure>

3. Add the token to the agent:

```bash
ngrok config add-authtoken <your-auth-token>
```

## Publish your local build

Start your local build and check which port it uses.

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2FdOc21hLl0FptbfoGAuY9%2FZrzut%20ekranu%202023-04-21%20095724.png?alt=media&amp;token=f2e17c00-48a4-46a5-b25d-b4886c515ed7" alt=""><figcaption></figcaption></figure>

Then run ngrok with that port, for example **3000**:

```bash
ngrok http 3000
```

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2FLyRKAa1MOaM0bSTVUljo%2FZrzut%20ekranu%202023-04-20%20155026.png?alt=media&amp;token=e08c0c19-0e63-4b5f-bff2-8292df16208c" alt=""><figcaption></figcaption></figure>

ngrok prints the public URL of your local build. You can open it in your browser to check that it works.

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2F17wld6wsZR8JRD5FNZMy%2FZrzut%20ekranu%202023-04-21%20100114.png?alt=media&amp;token=b3f69e44-6118-4663-a195-24ff2593e6d8" alt=""><figcaption><p>You can check it in the browser.</p></figcaption></figure>

### If your page is on a private server

If the website runs on a private server, you probably open it with a URL like `http://private.mycompany.com`. Create a tunnel to that address and let ngrok rewrite the `Host` header:

```bash
ngrok http --host-header=rewrite private.mycompany.com:80
```

ngrok prints the public URL in the same way.

## Use the ngrok URL in your tests

Use the URL provided by ngrok when you record a test or in the first step of an existing test.

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2FNTeLBaml8TwbIOsbOWL3%2FZrzut%20ekranu%202023-04-21%20102545.png?alt=media&amp;token=bc256662-5461-494d-9040-1b8b2ee441c4" alt=""><figcaption></figcaption></figure>

Every ngrok account, including a free one, has a dev domain that stays the same between restarts. If you use a different URL, update the tests when it changes:

1. Open a test and go to the first step.
2. Change the URL.

<figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2FraznaE9fpfgOsT0Hy0xE%2Fng%20url.png?alt=media&amp;token=5dd26400-4124-4b98-874a-e76e5fdad61e" alt=""><figcaption></figcaption></figure>

To maintain many tests more easily, keep the URL in a variable and use it in the tests. Then you change it in one place.

<div><figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2FDFG8T0C08BpSte1zPurz%2FZrzut%20ekranu%202023-04-21%20104317.png?alt=media&amp;token=f61b6625-90b7-41a6-b180-75eedb0f6709" alt=""><figcaption><p>Create a variable</p></figcaption></figure> <figure><img src="https://3168433179-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MKixgeBPbLvnD0l1eiV%2Fuploads%2F3hvknFbC5iLgyXHuUGSB%2FZrzut%20ekranu%202023-04-21%20104402.png?alt=media&amp;token=1e77596f-ca7d-4c0f-9d8a-b71da2b88ccd" alt=""><figcaption><p>Use it in test</p></figcaption></figure></div>

For more about variables, see [Variables](https://docs.bugbug.io/editing-tests/variables.md).

## Alternatives

ngrok has alternatives, and you can choose another tool:

* [Serveo](http://serveo.net/)
* [localhost.run](http://localhost.run/)
* [cloudflared](https://github.com/cloudflare/cloudflared)
* [LocalTunnel](https://github.com/localtunnel/localtunnel)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bugbug.io/running-tests/test-your-local-build-or-protected-web-page-using-ngrok.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
