Apple Terminal
Stops processesStop 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.
$ 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
printf '%s\n' 4242 4243printf '%s\n' 4242 4243 | xargs -n1 printf 'would kill pid %s\n'
next steps
Related commands
Find What Is Using a Local Dev Port
Your dev server says port 3000 is busy. Ask macOS who is holding it.
lsof -nP -iTCP:3000 -sTCP:LISTEN
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
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
Search a Log for Errors With Context
A wall of logs is useless until you pull the error and the lines around it.
grep -n -C 2 'ERROR' ./app.log
Watch a Log or Build File Update
Need to see whether a file is still changing? Let tail follow it live.
tail -f ./app.log
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.