Every Mac caches resolved DNS queries. Sometimes you get entries which create problems. To get rid of them you have to options: reboot the machine. This is the bad one. The good one is: Type the following command in the Terminal:
On Mojave you use
sudo killall -HUP mDNSResponder; sleep 2;
On older versions
dscacheutil -flushcache