Where is the Hosts File on Windows x64?

Helge Klein, 06/04/2009 | 25 Comments | 358,643 Views

[A German translation of this article is available at faq-o-matic.net.]

The subtle differences between 32-bit and 64-bit Windows present so many intricacies and pitfalls that even Microsoft employees seem to have trouble getting it right. I just stumbled upon a KB article that describes how to reset the hosts file to its original state. The topic alone is funny enough - it is not as if the default hosts file contained great amounts of data. An entry for localhost (IPv4 and IPv6) is all you need, and on Windows 7 / Server 2008 R2 not even that. But anyhow, there seem to be enough people asking MS support for this or they would not have troubled with creating a package (ResetHOSTSFileBackToDefaults.MSI) that basically empties the hosts file.

Is Hosts 64-bit or 32-bit?

As always, I am more interested in what the package does, and Microsoft is kind enough to explain that in most "Fix it for me" articles. As you probably know, the hosts file was, is and probably will always be located in %systemroot%\system32\drivers\etc. Simple enough. But wait: 64-bit systems have two system32 directories: one for 64-bit processes and the other for 32-bit processes. Now, where would the hosts file be located - or are there even two (potentially different) files?

The answer is: no, the hosts file exists only once on x64 Windows. And it is right where it belongs, in the 64-bit system32 directory. But where is that directory located on disk? Is it the one natively called system32, or is it SysWOW64?

Redirection Confusion

This is where confusion kicks in. Many people, including the person writing MS KB article 972034, see the number "64" in the name of the folder SysWOW64 and think: yes, that must be the 64-bit version of system32. Nice thinking, but wrong. It is exactly the other way round. For compatibility reasons, the name of the system32 folder did not change in Windows x64, although on 64-bit platforms the folder does not contain 32-bit but 64-bit executables! That leaves the question of where to put the 32-bit files that 32-bit processes need - and also expect to find in system32? Obviously, the same DLL cannot be present twice in the same folder.

The requirement of two different system32 directories was solved by redirection. Actually there are two independent folders in any x64 installation: system32 and SysWOW64. The latter is shown to 32-bit processes under the name system32. 64-bit processes do not use SysWOW64.

How to Get to and Edit the Hosts File

If you want to edit the hosts file, you first need to locate and open it - on Vista and newer with UAC enabled from an elevated process (with admin rights). The procedure is a little tedious. Here is how to do it with 64-bit Notepad:

  • Click on the Start button, type "notepad" and press CTRL+SHIFT+ENTER. Acknowledge the UAC dialog.
  • Type CTRL+O. Navigate to C:\Windows\System32\drivers\etc. Select "All Files" in the bottom right corner.
  • Now you see the hosts file. Select and open it. Make your changes and save it.

If you want to access hosts from a 32-bit process, use one of the following paths. Please note that in both cases the full path must be used. Navigating to "etc" from the root does not work (because System32 is redirected and Sysnative is not shown in directory listings).

  • %Windir%\System32\drivers\etc. This works because file system redirection is disabled for the "etc" directory and thus accessing the 64-bit System32 works from a 32-bit process.
  • %Windir%\Sysnative\drivers\etc. Sysnative is an alias that can only be used from 32-bit processes to access the 64-bit System32 directory.

+++ Your opportunity +++ Use Profile Migrator the new sepago product that makes migrating user personalities between different platforms a breeze.! Download your free version now!

25 responses for "Where is the Hosts File on Windows x64?"

So if a 32-bit app physically

So if a 32-bit app physically sees the SysWOW64 folder when accessing "%systemroot%\system32" and a 64-bit app physically sees system32 when accessing "%systemroot%\system32" then a 32-bit app looking to access the hosts. file will not get the real file?!? (or a "path not exist" error!)

32-bit and 64-bit Windows see

32-bit and 64-bit Windows see one and the same hosts file in system32 and SysWOW64 respectively. This is because redirection is disabled for the folder system32\drivers\etc. More information can be found here: http://blogs.sepago.de/helge/2008/04/20/windows-x64-all-the-same-yet-ver...

I just searched my 2008's

I just searched my 2008's Windows folder + all subfolders - no hosts file at all...so this article didn't bring me any closer...

I can suggest that you search

I can suggest that you search again!

And if you still don't find it, post the true name of your Windows operating system, and the exact path you searched into.

Funny. If you use MS

Funny.
If you use MS Explorer (F3) you will find it in \\\\"C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\drivers\\\\\\\\etc\\\\\\\\hosts\\\\" !!!

Tested on Windows server x64 2008 SP2

;-)

hi, i've tried to put machine

hi, i've tried to put machine ip to the hosts file on Win64 in \\\\"C:\\\\\\\\Windows\\\\\\\\System32\\\\\\\\drivers\\\\\\\\etc\\\\\\\\hosts\\\\" !!! but i'm not receiveing desired result as i have when i update hosts file on Win32, seems like there is no difference whether i update host file on 64bit or no.
Do you know what the reason can be?
i need to update hosts file for connection to machine that is in different domain

Anna, on Windows x64 the

Anna,
on Windows x64 the hosts file is stored in the (64-bit) System32 directory. In order to see that, either use a 64-bit program or, from a 32-bit program, use the following path:

%SystemRoot%\Sysnative\drivers\etc

Please note that the directory "System32" which you see from a 32-bit application is not the "real" System32, but a redirection to SysWow64.

thanks for reply! though it

thanks for reply!
though it says that : \"Windows cannot find \'c:\\windows\\Sysnative\\drivers\\etc\'. Check the spelling and try again.\"

The SysNative virtual

The SysNative virtual directory is available beginning with Server 2003 x64 SP2, I think.

Hello..... Hope you still

Hello.....
Hope you still look at this thread.
I'm still confused.
I would like to add several 127.0.0.1 addresses to block sites.
Where do I add these under the default 127.0.0.1 local host.
Which Hosts file locaton is the "master"?

fmg

As I wrote in the article,

As I wrote in the article, there is only one hosts file on Windows x64. From 32-bit processes it can be reached via this path:

c:\Windows\Sysnative\drivers\etc\

From 64-bit processes use the traditional path:

C:\Windows\System32\drivers\etc

Thanks for this great

Thanks for this great information. I\'m trying to create virtual sites on my local machine and I was confused after updating to Windows 7.

It seems that having

It seems that having 127.0.0.1 with a website name in the correct HOSTS file does not do anything. In fact, in Windows 7 the host file says that HOSTS are resolved in DNS itself. Is there anyway to get around this?

You are referring to the

You are referring to the following lines in the hosts file:

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

The comment simply means that the resolution of the name "localhost" is done in the IP stack. In other words, Windows understands that "localhost" is the local system and does not need to be looked up in DNS.

Have you set your Folder

Have you set your Folder Options to show the hidden system files? If not, open Explore, go to Tools/Folder Options/View and click in the radio button that says Show hidden files and folders. Click OK to close and save. Then search for 'hosts'

I suggest putting a shortcut

I suggest putting a shortcut on the desktop for quick updates to the 'hosts' file.
I find it to be one of the MOST useful files for blocking garbage URLs being accessed by otherwise useful sites for commercial or information gathering purposes. Keeping an eye on your status bar can be a very basic but often useful aid to alert you to some of this activity.

Hovering your mouse over junk ads can also give you additional info.

Also: If you can still find them, there are very good (reputable) 'host' files on the internet for legacy versions of windows ('95, '98, etc.) that you can copy or cut-and-paste into the win7 hosts file. These have hundreds of bothersome and downright nasty site addresses blocked in them, and are written in exactly the same format as the win7 file uses.

Please note the usage of the number sign (#) for adding your own comments to the host file. This comes in very handy for adding your own dates and notes if you find that you need to delete a particular blockage because it closes an entire site that you often use.

Thanks especially for the

Thanks especially for the explanations on redirection. I was always wondering how that worked. As you said, it's funny for the 64-bit libraries to sit in system32, but it is starting to make sense to me now. In any case, my edited "hosts" actually works, so that's great.
It's even scary how the redirection can mess up with your head. Windows Explorer Libraries introduced even more of that craziness, I wonder what Win8 will bring :)
Anyway, danke schön, Helge!

I have windows XP x64 and the

I have windows XP x64 and the folder /etc, /sysnative dont exist. Where can i find the host file? Txs.

Thanks, I need to say that

Thanks, I need to say that the "etc" directory don't list in Total Commander 7.50a. You need to go directly in explorer to the location of the file from Notepad with Administrative Rights, don't use others file manager softwares.

Or just run Notepad with administrative Rights and File-->Open write on filename "%Windir%\System32\drivers\etc" and click open, then you will be in the folder "etc". Change the file filter and open the file "hosts", edit and save.

Use "%Windir%\Sysnative\drivers\etc" where be needed. And error will be show if there is not for that version of Windows, so uses the first.

Thanks

I need to edit my win 7 64bit

I need to edit my win 7 64bit HOST file but all I can find & open is the "Sample" host file.. How do I find & access the actual HOST file?

Baco, by default "hosts"

Baco,
by default "hosts" (with trailing S) only contains comments, but it is still the correct file.

I cannot find the host file

I cannot find the host file at all. I see the sample and networks, protocol and services file but no host file. I have lmhosts.sam is all. Even did a search of the full drive. Any explanations?
Running 64 bit Windows 7

I you do not see directory

I you do not see directory etc in C:\Windows\System32 try with 64 bit native applicatioins.
When using for example 32 bit Total Commander - directory etc is invisible

Thanks...i got ur idea

Thanks...i got ur idea man!!!!!!!!!!

Thanks for the tip on where

Thanks for the tip on where to find the virtual hosts file x64 systems. I had no idea how to get about changing local address to redirect to where I wanted!

Tomek