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

posée 4 months ago210 vuesen

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.

Diagnostic IA

Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.

posée 4 months ago

2 réponses

5
✓
✓ Réponse acceptée

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.

Connectez-vous pour dire si ça a marché.

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.

Connectez-vous pour dire si ça a marché.

answered 4 months ago

Sign in and verify your email to post an answer.