Node.js: `EADDRINUSE: address already in use :::3000`

asked 4 months ago208 viewsen

3

I stopped my server with Ctrl+Z and now when I start it again I get Error: listen EADDRINUSE: address already in use :::3000.

AI diagnosis

AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.

asked 4 months ago

2 Answers

5
✓
✓ Accepted answer

Ctrl+Z suspends the process, it doesn't stop it. It's still holding port 3000. Use Ctrl+C to stop a server.

To find and kill whatever is on the port:

macOS / Linux

lsof -i :3000
kill <PID>

Windows (PowerShell)

Get-NetTCPConnection -LocalPort 3000 | Select OwningProcess
Stop-Process -Id <PID>

Or use npx kill-port 3000 on any OS.

Sign in to tell others whether this worked.

answered 4 months ago
1

In dev, it's also handy to read the port from the environment so you can just pick another one: const port = process.env.PORT ?? 3000; and then PORT=3001 npm run dev.

Sign in to tell others whether this worked.

answered 4 months ago

Sign in and verify your email to post an answer.