Skip to content

[Bug]: ECONNREFUSED, PW waits for a 2 mins timeout to start a server in WSL #40430

@bryndin

Description

@bryndin

Version

1.59.1

Steps to reproduce

This could be specific to WSL (Ubuntu running inside WSL with networking in a mirrored mode).
The run consistently takes 2.3 mins, with the 2 mins spent waiting for ECONNREFUSED
Changing b/w localhost (ipv6) and 127.0.0.1, trying different ports etc. doesn't help.

DEBUG=pw:webserver npx playwright test
  pw:webserver HTTP GET: http://localhost:1315/ +0ms
  pw:webserver Error while checking if http://localhost:1315/ is available: connect ECONNREFUSED ::1:1315 +2m
  pw:webserver Starting WebServer process npx serve public -l 1315 --no-clipboard... +0ms
  pw:webserver Process started +7ms
  pw:webserver Waiting for availability... +0ms
[WebServer]  INFO  Accepting connections at http://localhost:1315
[WebServer]  HTTP  4/26/2026 6:46:10 PM 127.0.0.1 GET /
...

playwright.config.ts

import { defineConfig, devices } from '@playwright/test';

const port = 1315;
const baseURL = `http://localhost:${port}`;

export default defineConfig({
  testDir: './tests/e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: 'html',

  use: {
    baseURL,
    trace: 'on-first-retry',
  },

  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],

  webServer: {
    command: `npx serve public -l ${port} --no-clipboard`,
    url: baseURL,
    reuseExistingServer: !process.env.CI,
  },
});

Expected behavior

Not to have this error and an extra 2 mins waiting time on every run.
pw:webserver Error while checking if http://localhost:1315/ is available: connect ECONNREFUSED ::1:1315 +2m

Actual behavior

DEBUG=pw:webserver npx playwright test
  pw:webserver HTTP GET: http://localhost:1315/ +0ms
  pw:webserver Error while checking if http://localhost:1315/ is available: connect ECONNREFUSED ::1:1315 +2m
  pw:webserver Starting WebServer process npx serve public -l 1315 --no-clipboard... +0ms
  pw:webserver Process started +7ms
  pw:webserver Waiting for availability... +0ms
[WebServer]  INFO  Accepting connections at http://localhost:1315
[WebServer]  HTTP  4/26/2026 6:46:10 PM 127.0.0.1 GET /
[WebServer]  HTTP  4/26/2026 6:46:10 PM 127.0.0.1 Returned 200 in 40 ms

  pw:webserver HTTP Status: 200 +3s
  pw:webserver WebServer available +1ms

Running 2 tests using 2 workers
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /about/
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 4 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 6 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /css/bundle.min.7f8fd7071af08cc8653cdfa9791f7ffc4e4b97bcfaf97a47550d9cad094b0f36.css
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /css/bundle.min.7f8fd7071af08cc8653cdfa9791f7ffc4e4b97bcfaf97a47550d9cad094b0f36.css
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /js/main.5a255add05038306f53d9b456dc1f604e8276dda46b0dd804270b2d27387826c.js
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /js/main.5a255add05038306f53d9b456dc1f604e8276dda46b0dd804270b2d27387826c.js
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 3 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 2 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 5 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 3 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-700.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-700.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-regular.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-300.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-regular.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-800.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-300.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 8 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-600.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 9 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 7 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 GET /fonts/manrope-v20-cyrillic_cyrillic-ext_greek_latin_latin-ext_vietnamese-800.woff2
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 7 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 8 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 7 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 3 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 8 ms
[WebServer]  HTTP  4/26/2026 6:46:11 PM ::1 Returned 200 in 9 ms

  pw:webserver Terminating the WebServer +2s
  2 passed (2.3m)

To open last HTML report run:

  npx playwright show-report

Additional context

Here's what LLMs say about it:

This output is absolutely fantastic and reveals exactly what the "freeze" is. It wasn't freezing forever; it was hanging for exactly 2 minutes due to a well-known networking quirk in WSL Mirrored Mode.
Look at these two lines from your log:
code
Text
pw:webserver HTTP GET: http://127.0.0.1:1315/ +0ms
  pw:webserver Error while checking if http://127.0.0.1:1315/ is available: connect ETIMEDOUT 127.0.0.1:1315 +2m
The Root Cause: The WSL TCP Blackhole
Before Playwright starts your webServer, it sends a quick HTTP request to see if the server is already running (to avoid starting a duplicate server).
Normally, on Linux or Mac, if a port is closed, the operating system instantly rejects the connection with an ECONNREFUSED error (this takes 1 millisecond).
However, in WSL Mirrored Mode, your network is bound to Windows. Unused ports route to the Windows Defender Firewall. Instead of cleanly rejecting the connection, the Windows firewall silently drops the network packets.
Because the packets are silently dropped, Node.js waits for the system's default TCP timeout (which is exactly 120 seconds, or 2 minutes) before it finally gives up (ETIMEDOUT).
Once those 2 minutes pass, Playwright goes "Okay, nothing is running, I'll start the server." It starts serve, the port opens, the firewall allows the traffic, and your tests run instantly and perfectly.
(Note: start-server-and-test didn't suffer from this because it uses a custom socket polling library that manually times out every 250 milliseconds, bypassing the Windows OS 2-minute timeout.)

Environment

System:
    OS: Linux 6.6 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
    CPU: (16) x64 AMD Ryzen 7 PRO 7840U w/ Radeon 780M Graphics
    Memory: 24.31 GB / 27.24 GB
    Container: Yes
  Binaries:
    Node: 24.14.1 - /home/xx/.nvm/versions/node/v24.14.1/bin/node
    npm: 11.11.0 - /home/xx/.nvm/versions/node/v24.14.1/bin/npm
  IDEs:
    VSCode: 1.111.0 - /mnt/c/Users/xxx/AppData/Local/Programs/Microsoft VS Code/bin/code
  Languages:
    Bash: 5.2.21 - /usr/bin/bash
  npmPackages:
    @playwright/test: ^1.59.1 => 1.59.1
    playwright: ^1.58.2 => 1.59.1
    playwright-core: ^1.58.2 => 1.59.1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions