Playwright "http://localhost:3000 is already used" webServer error in CI
With reuseExistingServer: false, Playwright wants to own the port but finds something already listening, so it stops. In CI this usually means a leftover server from a previous step, or another shard starting its own server on the same port.
What this error means
Startup fails with "Error: http://localhost:3000 is already used, make sure that nothing is running on the port/url specified by reuseExistingServer is not set to true".
Error: http://localhost:3000 is already used, make sure that nothing is running
on the port/url or set reuseExistingServer:true in config.webServer.Common causes
A leftover server still holding the port
An earlier step started the app and did not shut it down, so the port is occupied when Playwright tries to launch its own.
Multiple shards starting servers on one port
Each sharded job starts its own webServer on the same fixed port, so the second collides with the first on a shared host.
How to fix it
Reuse an already-running server intentionally
If something is meant to be running, set reuseExistingServer so Playwright attaches instead of starting a duplicate.
webServer: {
command: 'npm run start',
url: 'http://localhost:3000',
reuseExistingServer: true,
},Give each job an isolated port
Drive the port from an env var so shards and parallel jobs do not collide.
url: `http://localhost:${process.env.PORT || 3000}`,How to prevent it
- Stop background servers from earlier steps before Playwright starts.
- Use distinct ports per shard or parallel job.
- Set
reuseExistingServerdeliberately rather than leaving it default.