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

poze 4 months ago206 gadeen

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.

Dyagnostik IA

Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.

poze 4 months ago

2 Repons

5
✓
✓ Repons yo aksepte

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.

Konekte pou di lòt moun si li te mache.

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.

Konekte pou di lòt moun si li te mache.

answered 4 months ago

Sign in and verify your email to post an answer.