Error: listen EADDRINUSE: address already in use :::3000
bind: Address already in use
OSError: [Errno 98] Address already in use
Another process is already listening on the port you’re trying to use.
Fix 1: Find and Kill the Process
# Find what's using port 3000
lsof -i :3000 # Mac/Linux
netstat -tlnp | grep 3000 # Linux
# Kill it
kill -9 <PID>
# One-liner: kill whatever is on port 3000
lsof -ti :3000 | xargs kill -9
Fix 2: Use a Different Port
# Node.js
PORT=3001 node app.js
# Python
python manage.py runserver 8001
# Or set in .env
PORT=3001
Fix 3: Previous Process Didn’t Shut Down
# ❌ Ctrl+C didn't fully stop the server
# The process is still running in the background
# Find zombie Node processes
ps aux | grep node
kill -9 <PID>
# Or kill all Node processes
killall node
Fix 4: Docker Port Conflict
# ❌ Container or host already using the port
docker ps # Check running containers
# Use a different host port
docker run -p 3001:3000 myapp # Map host 3001 → container 3000
Fix 5: SO_REUSEADDR (Server Restart)
// Node.js — allow immediate port reuse after restart
const server = app.listen(3000);
server.on('error', (e) => {
if (e.code === 'EADDRINUSE') {
console.log('Port 3000 in use, retrying...');
setTimeout(() => server.listen(3000), 1000);
}
});
# Python
import socket
sock = socket.socket()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', 3000))
Fix 6: Windows
# Find process on port 3000
netstat -ano | findstr :3000
# Kill by PID
taskkill /PID <PID> /F