| name | ngrok-cli |
| description | Use ngrok to create secure tunnels to localhost, exposing local servers to the internet for webhook testing, demos, and remote access. |
ngrok
Secure tunneling to localhost. Expose local servers to the internet for webhooks, demos, and testing.
Authentication
ngrok config add-authtoken YOUR_TOKEN
Common Commands
HTTP Tunnels
ngrok http 3000
ngrok http 8080
ngrok http https://localhost:3000
ngrok http --url=myapp.ngrok.io 3000
TCP Tunnels
ngrok tcp 22
ngrok tcp 5432
Configuration
ngrok http 3000 --basic-auth="user:pass"
ngrok http 3000 --inspect=false
ngrok http 3000 --region=eu
Inspection
ngrok http 3000
API
ngrok api endpoints list
ngrok api tunnels list
Agent Best Practices
- ngrok runs as a foreground process - use
& or run in separate terminal
- The inspection UI at localhost:4040 shows all requests (useful for webhook debugging)
- Use
--log=stdout --log-format=json for parseable log output
- Free tier provides random URLs that change each restart
- Use
ngrok http for webhook testing (Stripe, GitHub, etc.)
- Kill the process to close the tunnel
- Parse the tunnel URL from the API:
curl -s localhost:4040/api/tunnels | jq '.tunnels[0].public_url'
Example Workflows
Expose local server for webhook testing
ngrok http 3000 &
sleep 2
TUNNEL_URL=$(curl -s localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url')
echo "Tunnel: $TUNNEL_URL"
Expose local dev server for mobile testing
ngrok http 3000