Skip to content
Latchkey

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".

playwright
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.

playwright.config.ts
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.

playwright.config.ts
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 reuseExistingServer deliberately rather than leaving it default.

Frequently asked questions

What causes ""... is already used, make sure that nothing is running""?
An earlier step started the app and did not shut it down, so the port is occupied when Playwright tries to launch its own.
How do I fix "... is already used, make sure that nothing is running"?
If something is meant to be running, set reuseExistingServer so Playwright attaches instead of starting a duplicate.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card