Clearing/Flushing Your Local DNS Cache (Windows, OSX)

We’ve all be there – you do a DNS lookup, and it’s still showing the wrong IP address, even though you know it’s since changed.  Well, DNS works on caching entries – what this means is, your local machine caches a lookup (for the duration of the TTL set by the DNS server) and your upstream DNS server caches the entry, and this happens until you get to the authoritive servers for that domain.  (You may be interested in reading the Wikipedia article on DNS:

There may be nothing you can do about your upstream DNS servers cache, but there is a way to flush your local machines cache, so at least that will refetch the DNS record from your DNS server(s).

The process is simple, in Windows you would use the command prompt (by running cmd.exe) or on OSX you can use Terminal:

OSX (Tiger, and below):

lookupd -flushcache

OSX (Leopard):

dscacheutil -flushcache
Windows (XP, Vista, 2003):
ipconfig /flushdns

Once you’ve done the above, when you lookup a name again on the machine, it’ll refetch the result from your DNS server(s).