Home › Linux & shell

Error: listen EADDRINUSE: address already in use — how to fix

Error: listen EADDRINUSE: address already in use :::3000

Quick fix: Find the process: sudo lsof -i :3000 (or sudo ss -ltnp 'sport = :3000'). Stop it with kill <PID>, or start your app on another port.

What it means

A TCP port can only have one listener per address. Your program tried to listen on a port that some other process (often an older copy of the same program) already holds.

The same problem appears under different names:

Find the process

sudo lsof -i :3000
# or
sudo ss -ltnp 'sport = :3000'

macOS: lsof -nP -iTCP:3000 -sTCP:LISTEN. Windows: netstat -ano | findstr :3000, then taskkill /PID <pid> /F.

Stop it

kill <PID>          # polite
kill -9 <PID>       # if it ignores the first one

One-liner (Linux/macOS): kill $(lsof -t -i :3000). Or npx kill-port 3000.

Common causes

Use another port

PORT=3001 npm start
python -m http.server 8001

TIME_WAIT after restart (Python, C)

If the port is "in use" for a minute after your own server stops, that's TCP TIME_WAIT. Set SO_REUSEADDR before binding:

sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

socketserver-based servers: set allow_reuse_address = True on the class.

Last updated 2026-10-27.