Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On Windows, how do you refresh the hosts file without rebooting?

share|improve this question
add comment

9 Answers

You don't need to reboot. Any changes you make to the hosts file are immediate. You used to need to reboot for changes to take effect in Windows 9x. That is no longer the case.

However, you may need to restart any applications that do internal hostname or DNS caching, such as web browsers.

share|improve this answer
5  
But you might need to reboot running applications since DNS entries might be cached. –  Barfieldmv Feb 28 '12 at 9:24
1  
Definitely add in the running applications DNS, as that's what ultimately matters. Firefox, from my knowledge and test a few moments ago, takes 60 seconds to refresh. –  Matthew Doucette May 21 '12 at 13:44
1  
Restarting Chrome won't pick up changes you make to your hosts file on Windows. Navigate to chrome://net-internals/#dns and press the "Clear host cache" button. –  2Toad Nov 27 '13 at 19:02
add comment

Have you tried ipconfig /flushdns ? I haven't found the need to reboot, though.

share|improve this answer
add comment

IE caches DNS entries. You need to start a new IE instance in order to see host file changes.

share|improve this answer
    
Firefox refreshes after about 60 seconds, you should double check that IE doesn't do a refresh too. –  Matthew Doucette May 21 '12 at 13:45
    
IE9 didn't detect the changes several minutes. So easier to use ipconfig /flushdns –  Marcus Aug 22 '12 at 12:20
add comment

Just a warning, NSLOOKUP will still retrieve results from DNS Server will never look at hosts file; To check if your new name works try the ping command.

share|improve this answer
add comment

ipconfig /flushdns will flush the local dns cache.
nbtstat -R will flush netbios cache. <----- Should be with Capital "R"

You may want to ensure there are no current connections to the host for which the name resolution you added by using netstat -a or something like tcpview.

Unless you have dns suffixing setup to append the domain names to the end of the host, you can usually tell if it is netbios by the use of a single name for resolution. It is common for corporate networks to suffix domains and add search orders to ease local resolution of hosts on the network.

I have noticed some of the applications I use also cache some of these responses, and must ensure they are completely closed before the resolution works properly. Firefox and IE like to occasionally run in the background, despite not having any active windows, but that may be more my fault than the applications.

share|improve this answer
add comment

Because changes are seen immediately, you might be seeing another DNS cache in your application. Firefox has a DNS cache with a TTL of around 60 seconds, I believe: I usually just restart firefox if I've made a change and can't wait a minute.

share|improve this answer
    
Thank you for this! I had no idea I only had to wait 60 seconds (I didn't time it but it's about this) for Firefox to update the DNS. Much better than if it takes more than 60 seconds to re-setup your workflow. –  Matthew Doucette May 21 '12 at 13:43
add comment

As @Ferruccio said, Hosts changes should be immediate in Windows. However, if you're using something like Microsoft Firewall Client Management software, that could be doing the DNS queries for you. Try disabling any proxy software and see if that works.

share|improve this answer
add comment

This helped for me once: "Restart the dnsclient service and DNS server service" Dave Guenthner [MSFT] Microsoft

share|improve this answer
    
For me, >ipconfig /flushdns alone did not work without reboot, but that followed by restarting dnsclient did. Thanks! –  Kristen Jukowski Dec 12 '13 at 17:26
add comment

I use Windows Vista connect to an office via a VPN. I use the LMHOSTS file to define names for IP addresses the other side of the VPN.

Unlike the other comments, I find that pinging a name after updating the LMHOSTS file does not use the new IP immediately. It does happen eventually but to speed up the process I use:

nbtstat -R

"-R (Reload) Purges and reloads the remote cache name table"

I have tried ipconfig /flushdns but it did not work for me.

[You have to open the command as an Administrator. Or run it from a command prompt with administrator privileges]

share|improve this answer
add comment

protected by Chris S Nov 20 '11 at 21:09

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?