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 use it to fix authoritative DNS propagation. It only affects your Mac.
Expected output
Usually no output, though sudo may ask for a password.
System impact
Stops processes. The local DNS cache is flushed 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 use it to fix authoritative DNS propagation. It only affects your Mac.
Recovery / rollback
No undo needed. DNS answers will be cached again naturally as you browse.
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' 'Before: example.com -> 192.0.2.10'
Before: example.com -> 192.0.2.10
$ printf '%s\n' 'sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' 'After: run a fresh lookup with dig example.com'
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
After: run a fresh lookup with dig example.com
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
printf '%s\n' 'Before: example.test -> 192.0.2.10'printf '%s\n' 'sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' 'After: run a fresh lookup with dig example.test'
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
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
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.