critical

net::ERR_CONNECTION_REFUSED

The browser could not connect to the target URL. The server is not running, the port is blocked, or the URL is incorrect.

Common Causes

  1. 1Development server is not running
  2. 2Wrong port number in the URL
  3. 3Server crashed during the test
  4. 4Firewall blocking the connection
  5. 5Container or service not yet ready in CI/CD

How to Fix

Use webServer config to auto-start your dev server

// playwright.config.ts
export default defineConfig({
  webServer: {
    command: 'npm run dev',
    port: 3000,
    reuseExistingServer: !process.env.CI,
  },
});

Playwright will automatically start your dev server before running tests and shut it down after.

Add a health check retry in CI

// wait-for-server.sh
for i in $(seq 1 30); do
  curl -s http://localhost:3000/health && exit 0
  sleep 1
done
exit 1

Wait for the server to be ready before running tests, with a 30-second timeout.

How ObserveOne Helps

ObserveOne monitors your application uptime 24/7, alerting you immediately when servers become unreachable.

Start Monitoring Free

Related Errors