Clear local DNS cache in macOS

To flush the local DNS cache for an Apple Mac running macOS 12.x (Sierra) or later do the following.

Start the Terminal App by going to Applications -> Utilities -> Terminal. Then, type the following command and press the ENTER key to execute:

sudo dscacheutil -flushcache

Now type the next command shown below followed by the ENTER key to execute:

sudo killall -HUP mDNSResponder

Now type the final command shown below followed by the ENTER key to execute:

sudo killall mDNSResponderHelper