闻心阁

一蓑烟雨看苍生,半壶浊酒笑红尘

How to Flush DNS Cache on Mac(include M1 M2)

2023-05-14 约 1 分钟读完 百宝箱

Recently, I’ve been migrating my person blog form Aliyun to Cloudflare Pages. When I modify the DNS record, I can’t visit the newest blog, so I need to flush the DNS cache.

What is DNS Cache?

DNS cache is a cache of DNS records, which is used to speed up DNS lookup. When you visit a website such as www.bbc.com, the DNS record would be record on local machine. When you visit www.bbc.com again, the DNS record would be found on your own machine quickly.

How to Flush DNS Cache?

Just using iterm / terminal or other terminal tools, open it, and input the command as follows:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Note: the command would request your password.

Other Methods

If your MacOS version is below 10.14 (Mojave), you can use the following command to flush DNS cache:

sudo killall -HUP mDNSResponder