Back to commands

Apple Terminal

Read-only, can be slow

Find 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.

next steps

Related commands

Apple Terminal Stops processes

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
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.

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.