From OS X 10.9 Mavericks to macOS 14 Sonoma, flush the DNS cache then restart DNS responder:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder