# Running ngrok in the background

By default, `ngrok` launches an interactive session. This is great for local development, but not if we're using it in an automated fashion (e.g. in CI). We can use this method to run `ngrok` in the background, and to acquire the randomly generated public url:

```bash
# run ngrok in the background
ngrok http 80 --log=stdout >/dev/null &
# get the public url
PUBLIC_URL=$(curl -sS http://localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url')
```

Source: [ngrok/issues/57](https://github.com/inconshreveable/ngrok/issues/57)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.eliasnorrby.com/tools/running-ngrok-in-the-background.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
