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.') );