Skip to content

Commit 4174284

Browse files
jin-2-kakaoenthyunjineeclaude
authored
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 <leehj0110@kakao.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent def2fd9 commit 4174284

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/browser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,18 +1523,18 @@ export class BrowserManager {
15231523
cdpUrl = cdpEndpoint;
15241524
} else if (/^\d+$/.test(cdpEndpoint)) {
15251525
// Numeric string - treat as port number (handles JSON serialization quirks)
1526-
cdpUrl = `http://localhost:${cdpEndpoint}`;
1526+
cdpUrl = `http://127.0.0.1:${cdpEndpoint}`;
15271527
} else {
15281528
// Unknown format - still try as port for backward compatibility
1529-
cdpUrl = `http://localhost:${cdpEndpoint}`;
1529+
cdpUrl = `http://127.0.0.1:${cdpEndpoint}`;
15301530
}
15311531

15321532
const browser = await chromium
15331533
.connectOverCDP(cdpUrl, { timeout: options?.timeout })
15341534
.catch(() => {
15351535
throw new Error(
15361536
`Failed to connect via CDP to ${cdpUrl}. ` +
1537-
(cdpUrl.includes('localhost')
1537+
(cdpUrl.includes('127.0.0.1')
15381538
? `Make sure the app is running with --remote-debugging-port=${cdpEndpoint}`
15391539
: 'Make sure the remote browser is accessible and the URL is correct.')
15401540
);

0 commit comments

Comments
 (0)