diff --git a/packages/playwright-core/src/utils/httpServer.ts b/packages/playwright-core/src/utils/httpServer.ts index 32012e6f96d1b..f387cefaa8d49 100644 --- a/packages/playwright-core/src/utils/httpServer.ts +++ b/packages/playwright-core/src/utils/httpServer.ts @@ -126,7 +126,8 @@ export class HttpServer { this._urlPrefix = address; } else { this._port = address.port; - this._urlPrefix = `http://${host}:${address.port}`; + const resolvedHost = address.family === 'IPv4' ? address.address : `[${address.address}]`; + this._urlPrefix = `http://${resolvedHost}:${address.port}`; } } return this._urlPrefix;