Skip to content
Latchkey

Storybook "storybook dev" port already in use in CI

Storybook binds a TCP port (6006 by default) to serve the dev preview. If another process already holds it, the dev server cannot start. In CI this usually means a previous Storybook was left running, or two steps race for the same port.

What this error means

Starting storybook dev fails with "Port 6006 is already in use" or Node prints "Error: listen EADDRINUSE: address already in use :::6006".

storybook
Error: listen EADDRINUSE: address already in use :::6006
    at Server.setupListenHandle [as _listen2] (node:net:...)

Common causes

A leftover Storybook process holds the port

A background storybook dev from an earlier step never exited, so the port is still bound.

Two steps bind the same port

A static server for the test-runner and a storybook dev both try to use 6006 concurrently.

How to fix it

Use a distinct port or a static build

  1. Prefer serving the static storybook-static for the test-runner instead of storybook dev.
  2. If you need dev mode, pass an explicit free port with -p.
  3. Ensure earlier background servers are stopped before rebinding.
Terminal
npx storybook dev -p 6007 --ci

Serve the static build for tests

A static server started with concurrently avoids a lingering dev server and is more reliable in CI.

Terminal
npx concurrently -k -s first \
  "npx http-server storybook-static --port 6006 --silent" \
  "npx wait-on tcp:127.0.0.1:6006 && npx test-storybook"

How to prevent it

  • Serve the static build rather than storybook dev in CI.
  • Use concurrently -k so background servers are torn down.
  • Pass an explicit free port when a default may be taken.

Frequently asked questions

What causes ""Port 6006 is already in use""?
A background storybook dev from an earlier step never exited, so the port is still bound.
How do I fix "Port 6006 is already in use"?
Use a distinct port or a static build

Related guides

References

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