How to fix net::ERR_CONNECTION_REFUSED in Playwright navigation?
Playwrightnet::ERR_CONNECTION_REFUSED means nothing is listening on the target host/port.
Start the web server before tests and verify baseURL or target URL.
// playwright.config.ts
export default {
use: { baseURL: 'http://127.0.0.1:3000' },
webServer: {
command: 'npm run dev',
url: 'http://127.0.0.1:3000',
reuseExistingServer: true,
},
};
This removes race conditions where tests run before the app is ready.