From 417428463bf34581816e01b24c536b7fcf6f2652 Mon Sep 17 00:00:00 2001 From: "jin.2" Date: Wed, 11 Mar 2026 18:15:21 +0900 Subject: [PATCH] Fix CDP connection failure on IPv6-first systems (#717) Use 127.0.0.1 instead of localhost when constructing CDP URL from port number, since Chrome only binds to IPv4. This prevents connection failures on systems like Ubuntu 24.04 where localhost resolves to ::1. Co-authored-by: hyunjinee Co-authored-by: Claude Opus 4.6 --- src/browser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/browser.ts b/src/browser.ts index 7c076cd..0d2ab4d 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1523,10 +1523,10 @@ export class BrowserManager { cdpUrl = cdpEndpoint; } else if (/^\d+$/.test(cdpEndpoint)) { // Numeric string - treat as port number (handles JSON serialization quirks) - cdpUrl = `http://localhost:${cdpEndpoint}`; + cdpUrl = `http://127.0.0.1:${cdpEndpoint}`; } else { // Unknown format - still try as port for backward compatibility - cdpUrl = `http://localhost:${cdpEndpoint}`; + cdpUrl = `http://127.0.0.1:${cdpEndpoint}`; } const browser = await chromium @@ -1534,7 +1534,7 @@ export class BrowserManager { .catch(() => { throw new Error( `Failed to connect via CDP to ${cdpUrl}. ` + - (cdpUrl.includes('localhost') + (cdpUrl.includes('127.0.0.1') ? `Make sure the app is running with --remote-debugging-port=${cdpEndpoint}` : 'Make sure the remote browser is accessible and the URL is correct.') );