Apple Terminal
Stops processesFlush macOS DNS Cache
macOS may keep using cached DNS answers after a domain, hosts entry, or local network record changes.
Command
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
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 treat this as a harmless read-only check. It changes local resolver cache state, may require admin authentication, and will not fix authoritative DNS propagation.
Expected output
Usually no output, though sudo may ask for an administrator password before changing the local DNS cache state.
System impact
Stops processes. The local DNS cache state changes: cached resolver answers are cleared, and mDNSResponder is signaled to reload.
May require elevated permissions on protected paths or service-owned files.
When to use it
Use after DNS changes, hosts file edits, local domain testing, or VPN resolver confusion.
When not to use it
Do not treat this as a harmless read-only check. It changes local resolver cache state, may require admin authentication, and will not fix authoritative DNS propagation.
Recovery / rollback
There is no direct undo for a flushed cache. DNS answers will be cached again naturally as you browse or run lookups.
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
Stop the Process Blocking a Dev Port
Free a stuck dev port without hunting through Activity Monitor.
lsof -ti tcp:3000 | xargs kill
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
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
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
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.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.