Skip to main content
Endpoints for monitoring server health and manually controlling the browser engine lifecycle.

Health check

Returns the current server and browser state. This endpoint is not logged to reduce noise in production logs.

Response

boolean
true if server is healthy, false if recovering from errors
string
Browser engine name: "camoufox"
boolean
true if browser is currently running and connected
boolean
true if browser process is active (same as browserConnected)
number
Total number of open tabs across all sessions
number
Number of consecutive navigation failures. Browser auto-restarts after 3 failures.
boolean
true if browser is currently restarting after detecting unhealthy state

Health states

Browser lifecycle

  • Browser launches lazily on first request (tab creation, navigation, etc.)
  • Browser shuts down after 5 minutes of inactivity when no sessions exist (configurable via BROWSER_IDLE_TIMEOUT_MS)
  • Browser auto-restarts after 3 consecutive navigation failures

Examples

Healthy (browser running):
Healthy (browser idle):
Recovering from errors:

Start browser

Manually launch the browser engine. Useful for pre-warming the browser before the first request.

Response

boolean
true if browser started successfully
boolean
true after successful launch

Example

Notes

  • If browser is already running, this endpoint is a no-op and returns success
  • First browser launch downloads Camoufox (~300MB) if not already installed
  • Subsequent launches take 2-5 seconds

Stop browser

Gracefully shut down the browser engine and close all sessions. Requires authentication.

Authentication

string
required
Bearer token matching the CAMOFOX_ADMIN_KEY environment variable:
If CAMOFOX_ADMIN_KEY is not set, this endpoint returns 403 Forbidden.

Response

boolean
true if browser was stopped successfully
boolean
false after shutdown

Example

Shutdown sequence

  1. All user sessions are closed (browser contexts)
  2. All open tabs are closed
  3. Browser process is terminated
  4. Browser will relaunch on the next request

Error responses

Missing or invalid admin key:
Admin key not configured:

Auto-recovery

The server automatically monitors browser health and restarts when necessary:

Failure detection

  • Tracks consecutive navigation failures
  • After 3 consecutive failures, browser is considered unhealthy
  • All sessions are closed and browser restarts
  • Success resets the failure counter

Disconnection handling

  • If browser disconnects unexpectedly, all sessions are cleared
  • Browser relaunches on the next request
  • Clients receive 500 errors during recovery

Idle shutdown

  • When no sessions exist for 5 minutes (default), browser shuts down to free memory
  • Server idle memory usage: ~40MB
  • Browser relaunches on the next tab creation

Configuration

Use cases

Health monitoring

Pre-warming

Graceful shutdown

Load balancer health checks

See also