> For the complete documentation index, see [llms.txt](https://notes.eliasnorrby.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.eliasnorrby.com/tools/running-ngrok-in-the-background.md).

# 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)
