Apple Terminal
Read-only, can be slowFind What Is Using a Local Dev Port
A local server will not start because another process is already listening on the same TCP port.
Command
lsof -nP -iTCP:3000 -sTCP:LISTEN
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not use it to inspect remote servers. It only checks the local Mac.
Expected output
A row showing the command name, PID, user, and LISTEN socket for port 3000.
System impact
Read-only, can be slow. Nothing changes. The command reports the process listening on the port.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use when Vite, Next.js, Rails, Django, or another local server refuses to bind to a port.
When not to use it
Do not use it to inspect remote servers. It only checks the local Mac.
Explanation-only example
Illustrated output, not a live lab run
This example is intentionally illustrative. It shows the command shape without killing real processes or changing your machine.
$ printf '%s\n' 'COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME' 'node 4242 uri 23u IPv6 0xabc 0t0 TCP *:3000 (LISTEN)'
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 4242 uri 23u IPv6 0xabc 0t0 TCP *:3000 (LISTEN)
$ printf '%s\n' 'COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME' 'node 4242 uri 23u IPv6 0xabc 0t0 TCP *:3000 (LISTEN)' | awk 'NR==1 || /LISTEN/'
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 4242 uri 23u IPv6 0xabc 0t0 TCP *:3000 (LISTEN)
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
printf '%s\n' 'COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME' 'node 4242 uri 23u IPv6 0xabc 0t0 TCP *:3000 (LISTEN)'printf '%s\n' 'COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME' 'node 4242 uri 23u IPv6 0xabc 0t0 TCP *:3000 (LISTEN)' | awk 'NR==1 || /LISTEN/'
next steps
Related commands
Stop the Process Blocking a Dev Port
Free a stuck dev port without hunting through Activity Monitor.
lsof -ti tcp:3000 | xargs kill
Flush macOS DNS Cache
Changed DNS but your Mac still visits the old place? Flush the resolver cache.
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Find Which Folder Is Eating Disk Space
When your Mac is full, start with the biggest folders in the current directory.
du -sh ./* 2>/dev/null | sort -h
See Exactly Which Command macOS Will Run
Before blaming npm, Python, or Git, check the binary your shell actually found.
command -v node && node -v
Check a URL Without Downloading the Page
Before opening a broken page in five browsers, ask the server for headers.
curl -I https://example.com
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.