{"record":{"id":"c1c718b20f06d645","repo":"dgtlmoon/changedetection.io","slug":"error-connecting-to-the-browser-exception-str","errorCode":null,"errorMessage":"Error connecting to the browser - Exception '{str(e)}'","messagePattern":"Error connecting to the browser - Exception '(.+?)'","errorType":"exception","errorClass":"BrowserConnectError","httpStatus":null,"severity":"error","filePath":"changedetectionio/content_fetchers/puppeteer.py","lineNumber":303,"sourceCode":"        logger.debug(f\"Extra wait set to {extra_wait}s, requested was {n}s.\")\n\n        from pyppeteer import Pyppeteer\n        pyppeteer_instance = Pyppeteer()\n\n        # Connect directly using the specified browser_ws_endpoint\n        # @todo timeout\n        try:\n            logger.debug(f\"[{watch_uuid}] Connecting to browser at {self.browser_connection_url}\")\n            self.browser = await pyppeteer_instance.connect(browserWSEndpoint=self.browser_connection_url,\n                                                            ignoreHTTPSErrors=True\n                                                            )\n            logger.debug(f\"[{watch_uuid}] Browser connected successfully\")\n        except websockets.exceptions.InvalidStatusCode as e:\n            raise BrowserConnectError(msg=f\"Error while trying to connect the browser, Code {e.status_code} (check your access, whitelist IP, password etc)\")\n        except websockets.exceptions.InvalidURI:\n            raise BrowserConnectError(msg=f\"Error connecting to the browser, check your browser connection address (should be ws:// or wss://\")\n        except Exception as e:\n            raise BrowserConnectError(msg=f\"Error connecting to the browser - Exception '{str(e)}'\")\n\n        # more reliable is to just request a new page\n        try:\n            logger.debug(f\"[{watch_uuid}] Creating new page\")\n            self.page = await self.browser.newPage()\n            logger.debug(f\"[{watch_uuid}] Page created successfully\")\n        except Exception as e:\n            logger.error(f\"[{watch_uuid}] Failed to create new page: {e}\")\n            # Browser is connected but page creation failed - must cleanup browser\n            try:\n                await asyncio.wait_for(self.browser.close(), timeout=3.0)\n            except Exception as cleanup_error:\n                logger.error(f\"[{watch_uuid}] Failed to cleanup browser after page creation failure: {cleanup_error}\")\n            finally:\n                self.browser = None\n            raise\n        \n        # Add console handler to capture console.log from favicon fetcher","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/dgtlmoon/changedetection.io/blob/5d9c7c6da76340597243e8163c4f2439237fa0e8/changedetectionio/content_fetchers/puppeteer.py#L285-L321","documentation":"Catch-all BrowserConnectError wrapping any other exception during the pyppeteer browser websocket connect, exposing the underlying exception string.","triggerScenarios":"Any non-InvalidStatusCode/InvalidURI failure: DNS resolution failure, refused connection, TLS error on wss://, timeouts, or incompatibility between pyppeteer and the browser's DevTools protocol.","commonSituations":"Browser container down; pyppeteer (unmaintained) vs modern Chrome protocol drift; network egress blocked; wss cert mismatch.","solutions":["Read the wrapped exception text — it names the real cause","Confirm the browser service is reachable: curl http://host:port/json/version","Switch the fetcher to Playwright (better maintained) instead of puppeteer","Fix DNS/TLS/network issues indicated by the inner message"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import socket\nfrom urllib.parse import urlparse\np = urlparse(browser_url)\ntry:\n    socket.getaddrinfo(p.hostname, p.port or 80)\nexcept socket.gaierror:\n    raise ConfigError('browser host unresolvable')","typeGuard":null,"tryCatchPattern":"try:\n    fetcher.fetch_page()\nexcept BrowserConnectError as e:\n    switch_fetcher('playwright')  # maintained fallback\n    retry_check()","preventionTips":["Prefer the Playwright fetcher; pyppeteer is unmaintained","Health-check the browser service before check runs","Pin compatible browser versions in deployment"],"tags":["websocket","puppeteer","connection","browser-service"],"backgroundTag":"websocket-connection-refused","analyzedSha":"5d9c7c6da76340597243e8163c4f2439237fa0e8","analyzedAt":"2026-08-27T19:41:16.067Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}