How to flush DNS cache in Linux / Windows / Mac

advertisement

Flush dns to get a new name resolution. Also flush dns cache when you can’t access a newly registered domain name. You can simply flush your dns cache anytime to get new entry. So, Flush your dns cache now.

To flush DNS cache in Microsoft Windows (Win XP, Win ME, Win 2000):-

- Start -> Run -> type cmd
– in command prompt, type ipconfig /flushdns
– Done! You Window DNS cache has just been flush.

To flush the DNS cache in Linux, restart the nscd daemon:-


– To restart the nscd daemon, type /etc/rc.d/init.d/nscd restart in your terminal
– Once you run the command your linux DNS cache will flush.

To flush the DNS cache in Mac OS X Leopard:-

- type lookupd -flushcache in your terminal to flush the DNS resolver cache.
ex: bash-2.05a$ lookupd -flushcache
– Once you run the command your DNS cache (in Mac OS X) will flush.

To flush the DNS cache in Mac OS X:-

- type dscacheutil -flushcache in your terminal to flush the DNS resolver cache.
ex: bash-2.05a$ dscacheutil -flushcache
– Once you run the command your DNS cache (in Mac OS X Leopard) will flush.

Technorati Tags: , , , , , , , , , , , , , ,

Related posts:

How to convert doc file to pdf file in Win XP - PDFCreator
How to Standardize Folder view setting in Microsoft Window XP
How to setup auto login in Microsoft Window XP?
How to disable auto login in window xp?
Disable Recent Documents History to get full privacy
How to enhance and increase battery life for N900
PHP Fatal error: Class ‘DOMDocument’ not found in …
Common MySQL database maintenance command






43 Responses to “How to flush DNS cache in Linux / Windows / Mac”

  1. dookie says:

    /etc/init.d/nscd reload

    will clear the cache without having to brute with a /etc/init.d/networking restart

  2. Uwe says:

    Was in the need for this for Mac, found your page as the first Google result :-) Thank you!

  3. valis says:

    on SLES 10
    rcnscd restart

  4. Kolade says:

    This really worked for me. Sometimes clearing DNS cache will help you see the recent changes made to any site you visit.

  5. Krish says:

    Hey,
    I mistakenly typed dscacheutil – flushcache. I put a dash and a space after it. Now is that an issue or something. Is there any way I can undo that.
    Hope to hear soon.
    Thanks

  6. logicmonkey says:

    other comments on Linux flushing are correct. simply restarting nscd will *NOT* flush the cache.

    # nscd -i hosts

    will invalidate the hosts table on CentOS/RHEL, but *ONLY* if the daemon is running in the first place. so don’t bother restarting, stopping or starting.

    just run this – as Wes has already said.

  7. Samuel Creshal says:

    The Linux variant is just wrong. I don’t know of *any* distribution that’s using nscd as default, Darkmage’s variant only works for Debian(+based?), and some distributions don’t have any builtin mechanism at all.

    Please make clear for which distributions your code works, and don’t claim it works “in Linux”. It doesn’t.

  8. Wes says:

    The Linux command listed does not work on RHEL/CentOS. Here’s the correct command:

    nscd -i hosts

  9. Joe says:

    The instructions for Linux are incorrect. The Linux kernel does not do DNS caching. User applications do, such as nscd daemon, but if you didn’t install it in the first place, your not running it, since it is not part of the standard setup. Applications such as Firefox also perform DNS caching by default.

  10. Mike says:

    These instructions for Mac OS X and Leopard are mixed up

    To flush the DNS cache in Mac OS X Leopard:-

    – type lookupd -flushcache in your terminal to flush the DNS resolver cache.
    ex: bash-2.05a$ lookupd -flushcache
    – Once you run the command your DNS cache (in Mac OS X) will flush. <——-

    To flush the DNS cache in Mac OS X:-

    – type dscacheutil -flushcache in your terminal to flush the DNS resolver cache.
    ex: bash-2.05a$ dscacheutil -flushcache
    – Once you run the command your DNS cache (in Mac OS X Leopard) will flush. < ——

  11. Darkmage says:

    For linux this is the proper one: sudo /etc/init.d/dns-clean start

  12. captain says:

    I believe you have the instructions for OSX and OSX-Leopard+ backwards. dscacheutil -flushcache is used in Leopard and SnowLeopard.

  13. Ammad says:

    its not working on RHEL, enen though i have restarted, named, network service and nsdc.

    thanks

  14. hic says:

    even tried lookupd -flushcache, still aint working.

  15. hic says:

    i cant seem to flush on my mac 10.4
    typed in dscacheutil -flushcache in terminal
    but says, command not found?

  16. Tricky says:

    @Dad, kyle, daftwill123, and SoGua: should probably be *restart* the “DNS Client” service. If it isn’t already started then the service would have been disabled and there’s nothing to flush. Best to also check that the service is set to start on startup within the Right-click Properties dialog box.

    @sweet bunny: I don’t believe any Windows versions prior to Windows 2000 did any caching at all without specifically installing a DNS caching service. Chances are the issue was with an upstream DNS server or maybe your firefox cache as per. See below or SoGua’s comment from August 7th 2007.

    Re nscd, many *nix distros don’t have nscd installed by default. If “nscd -i hosts” doesn’t clear the cache (that’s the correct way to flush it btw) then installing it won’t help you except to install an empty cache. Also, there could be other daemons installed instead of nscd, dnsmasq or bind for example (Bind is generally not the best for a desktop – but is still installed on a lot of servers). Bind’s cache can be flushed with “rndc flush”. Dnsmasq I believe has to be restarted for the cache to be flushed.

    Lastly, there’s also a lot of upstream cached records that might be totally outside of your control. In case your current DNS server has the incorrect info cached, try changing your caching DNS server settings in your Network Settings to use a different server.

  17. daftwill123 says:

    Thank you!!!

  18. SoGua says:

    Ok here’s another solution: Go to Control Panel -> Administrative tools -> Services and look for “DNS Client” and right click on it and Select Start. Once DNS client started you can try to flush the DNS again.

  19. daftwill123 says:

    Thanks for the advice. I’ve ran anti-virus many many times, cleared out the system over and over of both spyware and virus and still having trouble. It might be so deep into the system though my protection programs aren’t picking them up. I’m using the latest versions of AVG Free (AVG 8) and Spyware search and destroy.

  20. chua says:

    Hi daftwill123, i suspect your PC was infected by virus.
    Do a full system scan with your anti virus.

    Here’s a free antivirus
    http://www.techiecorner.com/102/avast-anti-virus-free-anti-virus-software/
    http://www.techiecorner.com/166/avast-how-to-schedule-boot-time-scan-before-window-start/

  21. daftwill123 says:

    I’ve get the same error message as Dad:

    C:\WINDOWS\Dad>ipconfig/flushdns

    Windows IP Configuration

    Could not flush the DNS Resolver Cache: Function failed during execution.

    C:\WINDOWS\

    I tried what Kyle said and it pretty much changed nothing. Though he said something about Windows Vista and both me and Dad are on XP. I’m trying to do this to see if it will let me re-connect to google because I can’t connect to google and so far only google. If any of you got suggestions on that too, to help me re-connect, that’d be awesome.

  22. Mike says:

    For all the Windows people the command is:

    ipconfig \flushdns

    Everyone has the slash the wrong way

  23. Moritz says:

    Debian 4.0 Konsole

    /etc/init.d/networking restart

  24. John says:

    you have the leopard / non-leopard instructions backwards – pre-leopard uses lookupd

  25. Jon says:

    I had the same issue after I installed BIND 9 and racked my brains as a deconstructed my setup on my Ubuntu system. Finally tried editing /etc/hosts and found my localhost entry munged and repaired it. FireFox instantly began resolving again. Go figure. Note that I did retain the DNS server on board – Also, I found that you can use the “PortableApps” Firefox browser with Wine to work as a spare tire of sorts, since it was what got me through this. Just have Wine installed and then use the PortableApps Firefox browser.

    Good luck.

    Jon

  26. sweet bunny says:

    I can’t flush my dns cache in win98.

    ipconfig/flushdns is a bad command

    I am unable to get to certain websites on both ie and firefox

    I was able to get to the sites at one time, but once I get the server not found message i can’t get to the site.

    Thanks for any help

  27. Mothership says:

    Ryan,

    that’s because the headings for the two Mac OS X commands are around the wrong way.

    If you’re using 10.5, use: dscacheutil -flushcache

    Also, you want everything after the $ sign. The rest is what is written before the command prompt.

  28. [...] rnrn rn rn rn Re: flush DNS on Linuxrn rn rn rn rn rn Does this help?rnrnHow to flush DNS cache in Linux / Windows / Mac – Techie Cornerrn rn rn rn rn rnrn rn rn rn __________________rn Marcel Coxrn rn rn [...]

  29. Ryan says:

    bash-2.05a$ lookupd -flushcache

    When I try this on my Mac I get a command not found?

    ryan-imac:~ ryan$ bash-2.05a$ lookupd -flushcache
    -bash: bash-2.05a$: command not found
    ryan-imac:~ ryan$

  30. sli says:

    in MacOSX Leopard 10.5.2 its :

    dscacheutil -flushcache

  31. /etc/init.d/network restart

    Will clear the cache on Linux.

  32. kyle says:

    Hey dad.. try this.

    1. Click the Microsoft Vista Start logo in the bottom left corner of the screen
    2. Click All Programs
    3. Click Accessories
    4. RIGHT-click on Command Prompt
    5. Select Run As Administrator
    6. In the command window type the following and then hit enter: ipconfig /flushdns
    7. You will see the following confirmation:

    Windows IP Configuration
    Successfully flushed the DNS Resolver Cache.

  33. Jason says:

    Sam, which version of firefox has that option?
    I cannot locate it in my about:config

  34. Dad says:

    Can someone help…! I can’t Clear my Cache…

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\Dad>ipconfig /flushdns

    Windows IP Configuration

    Could not flush the DNS Resolver Cache: Function failed during execution.

    C:\Documents and Settings\Dad>

  35. Mohan.R says:

    Hello Sir………..

    To whom ever it may concern……………
    Can you give me a solution for this………
    Here we are using Terminal server with more than 50 clients at a time……..
    but when i shutdown and restart that server then it will shows some errors
    “IEXPLORER has encounter a problem”…………. Please can you give me a solution for this…………….. And we are using Domain environment also. Please give a solution for this……

  36. Sam says:

    firefox’s about:config has an option: network.dnsCacheEntries
    setting this to 0 will disable the cache and fallback to the local DNS cache.

  37. SoGua says:

    Normally the internal firefox cache will be clear once you close all the browser.

  38. wululululu says:

    i think gabriel means the internal firefox dns cache (yes firefox has it’s own dns cache… unnecessarily)
    but i don’t know how to flush it… the only thing i can change, is the expiration interval.

  39. sogua says:

    gabriel: this only flush ur pc dns cache. if you wan to clear Firefox internal cache, you can open firefox -> Tools -> Clear Private Data (Check the cache) and click “Clear Private Data Now”

  40. gabriel says:

    this does NOT flush firefox internal cache.

  41. [...] | DosBit – Techie Corner Publicaciones [...]

  42. acklan says:

    ipconfig /flushDNS dos not work with Windows 9x\ME

  43. Benjamin Schmidt says:

    On my Debian machine, the nscd daemon is not installed by default. (/etc/rc.d/init.d/nscd missing)

    Description:
    A daemon which handles passwd, group and host lookups
    for running programs and caches the results for the next
    query. You should install this package only if you use
    slow Services like LDAP, NIS or NIS+

    So i think “/etc/init.d/network restart” does also clear the cache. Does anyone know a better solution, let me know

Leave a Reply