Back to commands

Apple Terminal

Stops processes

Stop the Process Blocking a Dev Port

A stale local server keeps listening on a port after its terminal window was closed.

Command

lsof -ti tcp:3000 | xargs kill

Before you run this

System impact: Stops matching processes. Can interrupt apps, databases, sync tools, or system services if the PID list is wrong.

When not to use it: Do not use on ports for databases, sync tools, system services, or any process you do not recognize.

Expected output

Usually no output. Running the port check again should show no listener.

System impact

Stops processes. The process IDs returned by lsof are asked to stop with a normal TERM signal.

When to use it

Use only when you are confident the process on that port is your stale local dev server.

When not to use it

Do not use on ports for databases, sync tools, system services, or any process you do not recognize.

Recovery / rollback

Restart the stopped application or dev server if you killed the wrong process.

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.

demo@lab:~$

$ printf '%s\n' 4242 4243

4242
4243

$ printf '%s\n' 4242 4243 | xargs -n1 printf 'would kill pid %s\n'

would kill pid 4242
would kill pid 4243
View commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  1. printf '%s\n' 4242 4243
  2. printf '%s\n' 4242 4243 | xargs -n1 printf 'would kill pid %s\n'

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.

  • lpic1:109-networking
  • lfcs:networking
  • linuxplus:provisional
  • linuxplus:troubleshooting
  • risk:macos-only
  • risk:production-state-change

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.