```yaml
product: AlterLab
title: "Proxy Tunnel Health Checks for Headless Browsers | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/answers/proxy-tunnel-health-checks-before-browser-commands
```

# Checking Proxy Tunnel Health Before Sending Browser Commands

## Short answer

### How should a proxy rotation wrapper check tunnel health before a headless browser runs a command?

Before each navigation, send a cheap request through the same tunnel, such as a HEAD to a known endpoint, with a short timeout. Only issue the browser command if it succeeds; otherwise mark the exit unhealthy, rotate to a fresh one and retry. AlterLab runs these checks and rotation automatically for every request.

## Step by step

1. 1
   ### Probe through the exact tunnel
   Send the health check through the same proxy session the browser will use, not a fresh connection, so you test the path the command will take.
2. 2
   ### Use a short timeout
   Give the probe 2-5 seconds. A slow tunnel that passes after 20 seconds will time out the real page load anyway.
3. 3
   ### Quarantine failing exits
   Move an exit that fails the probe into a cool-down list for a few minutes instead of retrying it immediately.
4. 4
   ### Rotate and replay
   Open a new browser context on a healthy exit and replay the command. Keep cookies only if the new exit is in the same region.

## Example

Python

```
import httpx

def tunnel_is_healthy(proxy_url: str) -> bool:
    try:
        with httpx.Client(proxy=proxy_url, timeout=4.0) as client:
            return client.head("https://example.com/").status_code < 500
    except httpx.HTTPError:
        return False

# Only hand the proxy to the browser once the probe passes
if tunnel_is_healthy("http://user:pass@proxy.example:8000"):
    print("tunnel ok - run browser command")
```

## Frequently Asked Questions

### How often should I re-check a tunnel?

Before every navigation that matters, or at least every 30-60 seconds on a long-lived session. Residential exits can drop at any moment, so a check made minutes ago says little about the next request.

### Can I skip health checks with a managed API?

Yes. With AlterLab you send the target URL and the platform picks a healthy exit, retries on failure and returns the page, so no tunnel management code is needed in your scraper.

## Read the full guide

[Building proxy rotation wrappers with tunnel health checks](https://alterlab.io/blog/building-custom-proxy-rotation-wrappers-with-automated-tunnel-health-verification)

## Related answers

[Redundant Cross-Border Proxy Pools That Rotate When Throttled](https://alterlab.io/answers/redundant-cross-border-proxy-pool-rotation)[Rate Limiting, Retries, Backoff and Connection Pooling in Python](https://alterlab.io/answers/python-scraping-rate-limit-retry-backoff-pooling)

## Try it with AlterLab

Send a URL, get the page back as HTML, markdown or JSON. Rendering, proxy rotation and retries are handled for you.

[View API docs](https://alterlab.io/docs/api/rest)

## Your first scrape. Sixty seconds.

Up to 5,000 free requests — about 5,000 direct fetch, 500 managed sessions or 250 full browser rendering requests. No credit card. 
Just a POST request.

terminal

curl -X POST https://api.alterlab.io/v1/scrape \

-H "X-API-Key: YOUR_KEY" \

-H "Content-Type: application/json" \

-d '{"url": "https://example.com", "formats": ["markdown"]}'

[Start building free](https://alterlab.io/signin)

No credit card required · Up to 5,000 free requests (about 5,000 direct fetch, 500 managed sessions or 250 full browser rendering requests) · Balance never expires