According to Apple: “OS X keeps a local cache of resolved DNS queries for a time defined by the DNS server, but sometimes it may be necessary to reset the cache immediately and re-query a DNS server. For example, you might do this after an entry on the server is changed or a new entry is added.”
Below are steps for clearing the Cache in Yosemite and older. If you have High Sierra or newer, use this link to clear the Mac OS DNS Cache in High Sierra and newer.
To flush the DNS Cache on Yosemite (OSX 10.10) from terminal:
sudo discoveryutil udnsflushcaches
To flush the DNS Cache in Mavericks (10.9), Mountain Lion (10.8), and Lion (10.7), run the following command from terminal (Applications > Utilities > Terminal): sudo killall -HUP mDNSResponder
For older Mac OS X Leopard (10.5) and Snow Leopard (10.6), run this command in Terminal:
sudo dscacheutil -flushcache
I have found that despite clearing the DNS cache, Safari may still hold on to old records, so I usually have to quit Safari before clearing the cache, or open another browser like Chrome which is not holding on to old DNS information.
network-tools.com is a useful site for testing DNS resolution from the internet, taking your machine and its DNS cache out of the equation.