Resolving Port Conflicts (EADDRINUSE)
Diagnose and resolve port collisions, find the holding Process ID (PID) using lsof, netstat, and ss, and terminate stale processes.
What is a Port Conflict (EADDRINUSE)?
In TCP/IP networking, only one process can bind to a specific (IP Address, Port Number) combination at any given time. If an application attempts to start on a port that is already in use by another process (or a previous zombie instance that didn't terminate cleanly), the operating system returns an EADDRINUSE error:
Error: listen EADDRINUSE: address already in use :::30003-Step Fix Workflow
1. Identify the holding PID (Process ID)
│
▼
2. Verify process identity (Ensure it's safe to kill)
│
▼
3. Terminate process (kill -9 <PID>)1. macOS & Linux: Finding and Killing with lsof
# Step 1: Find the PID listening on port 3000
lsof -i :3000
# Output example:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# node 14285 user 23u IPv6 0x1234567890abcdef 0t0 TCP *:3000 (LISTEN)
# Step 2: Kill the process by PID (Try SIGTERM first, fallback to SIGKILL)
kill 14285
# or if unresponsive:
kill -9 14285One-Liner Quick Kill (Development Only)
# Gracefully kill holding process:
kill $(lsof -t -i :3000)
# Force kill if stuck:
kill -9 $(lsof -t -i :3000)2. Linux: Using ss / fuser
# Find with ss
sudo ss -tulpn | grep :3000
# Kill holding process with fuser
sudo fuser -k 3000/tcp3. Windows (PowerShell / CMD)
# Find holding PID on Windows
netstat -ano | findstr :3000
# Terminate process by PID
taskkill /PID 14285 /Flocalhost (127.0.0.1) vs 0.0.0.0 Binding
Understand network interface binding, why binding to 127.0.0.1 breaks Docker containers and mobile testing, and when to use 0.0.0.0.
CORS vs Networking & Firewalls
Demystify why CORS is strictly a browser security policy and why network firewalls, curl, and backend servers never experience CORS errors.