Repository navigation
Description
What's going on?
In Playwright CLI and MCP server (playwright open, tab-new, browser_navigate), when opening or navigating to URLs specified without an explicit scheme:
-
Bare loopback IP addresses fail with
net::ERR_SSL_PROTOCOL_ERROR:
When targeting local development servers on loopback IPs (e.g.,127.0.0.1:3000,0.0.0.0:8000,[::1]:8080), navigation fails immediately:page.goto: net::ERR_SSL_PROTOCOL_ERROR at https://127.0.0.1:3000/This happens because
checkUrlAndNavigateonly checksurl.startsWith('localhost')before defaulting tohttps://. As local development servers predominantly run on plain HTTP, forcinghttps://causes SSL protocol failure. -
Bare hostnames with ports fail with
net::ERR_ABORTED:
When specifying a bare host with a port (e.g.,example.com:8080), navigation fails:page.goto: net::ERR_ABORTED at example.com:8080According to the WHATWG URL standard,
new URL('example.com:8080')parses successfully withprotocol: "example.com:"andpathname: "8080". Becausenew URL(...)does not throw an error, thetry / catchblock incheckUrlAndNavigateis bypassed entirely, leaving the raw string without anhttp://orhttps://scheme.
Visual Evidence
1. Reproduction — SSL Protocol Error on Loopback IP & Aborted Custom Scheme:

2. Fixed Behavior — Loopback IPs and Ported Hosts Normalized Properly:

Why does this happen?
In packages/playwright-core/src/tools/backend/tab.ts:
async checkUrlAndNavigate(url: string): Promise<string> {
try {
new URL(url);
} catch (e) {
if (url.startsWith('localhost'))
url = 'http://' + url;
else
url = 'https://' + url;
}
this.context.checkUrlAllowed(url);
await this.navigate(url);
return url;
}- WHATWG
new URL()does not throw onhost:portbecausehost:is treated as a valid scheme name ifhostbegins with an ASCII alpha character ([a-zA-Z]). - Loopback IPs begin with numbers (
127.0.0.1) sonew URL()throws, but the catch branch only checkslocalhost, falling through tohttps://for all IPv4/IPv6 loopback addresses.
Expected behavior
- URLs without an explicit scheme (
^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/or^(about|data|blob|javascript):) should be normalized. - Local loopback addresses (
localhost,127.0.0.1,0.0.0.0,[::1]) should default tohttp://. - Other bare hosts (e.g.
example.com:8080,playwright.dev) should default tohttps://.
Activity
chore: mark v0.1.23 (#494)