Fix guides / Replit / Node: "Error: listen EADDRINUSE: address already in use"

How to fix "listen EADDRINUSE: address already in use"

You press Run and the server dies with Error: listen EADDRINUSE: address already in use :::3000. Something is already listening on that port: usually an earlier copy of your own server that did not shut down, or two parts of your app trying to use the same port.

Fix 1: stop the old process

In the Replit Shell or your terminal:

npx kill-port 3000
# or
lsof -i :3000      # shows the process ID
kill -9 <PID>

On Replit, stopping the Repl fully and pressing Run again also clears stuck processes.

Fix 2: your app starts the server twice

Very common in AI-generated code: app.listen() appears in both server.js and index.js, or a dev script runs the API and also imports it into another process. Search for it:

grep -rn "listen(" --include=*.js --include=*.ts --exclude-dir=node_modules .

Keep exactly one listen call. If you run a front end and an API together (for example with concurrently), give them different ports.

Fix 3: use the port the host gives you

const PORT = process.env.PORT || 3000;
app.listen(PORT, '0.0.0.0', () => console.log('listening on', PORT));

Replit deployments and most hosts set PORT. Binding to 0.0.0.0 rather than localhost is also what Replit's deployment health check expects.

Fix 4: watchers restarting too fast

With nodemon or tsx watch, a restart can begin before the old server closes. Close the server on shutdown signals:

const server = app.listen(PORT);
for (const sig of ['SIGINT','SIGTERM']) process.on(sig, () => server.close(() => process.exit(0)));

Check the fix

  1. Run the app twice in a row; the second start should not fail.
  2. The live preview loads on the expected port.
Still stuck? No shame in it: these bugs hide in settings your AI builder cannot see. Send us the error and your repo and we will fix it as a pull request within 24 hours, explained in plain English, for $49. Several things broken? The $149 Full Rescue covers up to 3 issues plus a security pass, within 72 hours. Not fixed means full refund.
Quick Fix, $49Full Rescue, $149Ask first

Last updated 2026-10-19.