Back to commands

Apple Terminal

Stops processes

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

demo@lab:~$

$ 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

  1. printf '%s\n' 'Before: example.test -> 192.0.2.10'
  2. printf '%s\n' 'sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' 'After: run a fresh lookup with dig example.test'

next steps

Related commands

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:104-filesystems-permissions-fhs
  • lpic1:107-admin-tasks
  • lpic1:110-security
  • lfcs:users-groups
  • linuxplus:provisional
  • linuxplus:security
  • linuxplus:troubleshooting
  • risk:macos-only
  • risk:production-state-change
  • risk:security-sensitive

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.