Home » All » Customization » Vista » Windows | All Categories

Published on 01.13.07 by Brent Trahan

Edit the Windows Vista Hosts File

How to edit the hosts file in Windows Vista.


I develop and manage my websites and need to edit my hosts file when I’m at certain locations to bypass DNS settings when testing new sites.

It took me a little while and a little research but I figured out how to edit the hosts file in Vista.

Edit the Hosts File

Non-frequent Edit

  1. Open Notepad with Administrative privileges by clicking Start, All Programs, Accessories, and then right-click Notepad and select to open as Administrator.
  2. Now that Notepad is open with Administrative privileges browse to (C:\Windows\System32\drivers\etc) in Notepad and open the hosts file.

Now you can edit and save the hosts file.

Frequent Editing

I sometimes frequently edit my hosts file and like a shortcut on my desktop for easy editing. Here’s how to create a shortcut on your desktop and lets you quickly and easily open your hosts file with Notepad and edit it.

  1. Send a shortcut to Notepad to your desktop by right-clicking Notepad in the start menu and selecting send to desktop.
  2. Right-click the shortcut to Notepad on your desktop and select properties.
  3. Click the advanced button near the bottom of the shortcut tab and check off run as administrator. Click OK in the advanced properties window.
  4. Replace %SystemRoot%\system32\notepad.exe with %SystemRoot%\system32\notepad.exe C:\Windows\System32\drivers\etc\hosts in the target box. Click OK in the properties window to save the changes.

Now all you have to do is open that shortcut to open your hosts file with Notepad with administrative privileges.

Thanks to the first few commenters on this guide for pointing this out to me.

Still need help? Ask your computer question now.

Related Guides:

77 Responses to “Edit the Windows Vista Hosts File”

Subscribe to this guide's comments RSS feed.

  1. Munir says:

    You also could just open your editor with administrator privileges (right-klick, “Run as administrator”).

  2. Thava says:

    Thanks for this information.

    It was useful for me.

    / Thava

  3. Jim says:

    Hey guys, heres a better way.

    Create a new short cut pointing to:

    C:\Windows\System32\notepad.exe C:\Windows\System32\drivers\etc\hosts

    Open the properties and click the Advanced button on the Shortcut tab and select Run As Administrator.

    That’s it, this will allow you to edit the file in place in notepad.

  4. Joe Man says:

    Going to

    Accessories > Right Click Notepad > Run As Administrator.

    Open the file you want to modify.

    thats it.

    • sky says:

      I tried those 2 ways, i cannot save it to replace the hosts file. is somewhere wrong with my computer?
      I have second question: if i deleted all the content, just leave localhost over there, is that will affect my other computer system?
      Thanks in advance!

  5. Lars-Erik says:

    Nice to know! :) Vista’s a bit over the edge securitywise if you ask me..

  6. Alejandro Gonzalez says:

    Security in vista is kind of excessive, specially when you’re a developer and need to be working directly on some system file or process.

  7. Brent Trahan says:

    Being able to easily access and work with system files and processes is what made all earlier versions of Windows so unsecure but easy to use.

    Things have drastically changed in the past few years that made Microsoft harden Windows Vista.

    Most regular PC users will very rarely see UAC prompts once their PC has been set up and used a little.

  8. Ankur says:

    I have a serious problem with my Windows Vista Hosts file.

    I am getting this message while I am trying to save this file.

    Cannot Create c:\windows\system32\drivers\etc\hosts file.
    Make sure that the path name is correct.

    I have tried everything from Running notepad as administrator and even unclicking the Read Only property for my folders but no Use. Please help if anybody has any idea about this.


    • jordan says:

      i used to have that same problem, with the error “make sure your path name is correct”

      the only way i know to avoid that, is to move the hosts file to ur desktop and edit it there, once you’re done editing it, simply move it back into the original folder (c:/windows/system32/drivers/etc/)

      hope this helps

    • wietse says:

      you need to run a program cald hostsperm i dowloaded it from bleepingcomputer.com

  9. Brent Trahan says:

    So you can open and edit your hosts file but when you go to save your changes it gives you this error?

  10. Dan says:

    I have the same problem as Ankur… I have disabled UAC and tried that too :( (using vista business)

  11. Scott says:

    thanks! very useful!!

  12. Joel says:

    Check your firewall or other protective software. McAfee blocked my attempt to edit/delete the file as part of “protect network settings.”

  13. Justin says:

    Guys i dont have a hosts gile :(

    I am using a windows vista home premium.

    And idea what could be the problem.

    • Kiwimcb says:

      yh, i had tht problem aswell, there should be a drop down box saying text files. txt or something like tht, click on the box and change it to all files and it should show up

  14. Brent Trahan says:

    Are you positive you’re looking in the right place? There has to be a hosts file.

  15. Milad says:

    very usefull, thank you so much

  16. Prem says:

    Thanks Brent.

  17. kim says:

    Thanks very much ….. at least i can alter the hosts file now….. still hate vista but hey beggers cant be choosers!!


  18. j says:

    Thanks, that’s useful!

    Right now I’m as usual struggling against the Vista UAC, which was turned off last time I checked, in order to update this file.

    I paid for this computer and am FULLY QUALIFIED to update its system resources, but MS has decided to make simple tasks difficult to impossible.

    I expect my next computer will be a Mac

  19. jj says:

    Now that I’m done complaining about Vista, I’ll offer something constructive.

    One line command does the trick: C:\Windows\system32\notepad.exe C:\Windows\System32\drivers\etc\hosts

    If necessary revise for any customizations, of course.

    And do whatever it takes to overcome Vista UAC.

  20. amit says:

    yes it works

  21. Joe Wood says:

    How do I get to the Hoast file……..I have XP instead of Vista.
    Better still how do I get rid of b1.adv.net if I have XP? Thanks in advance. Please email me with answer….

  22. rahul says:

    i could not edit host file in window vista. i follow ur instructions but unable to did that, plz give me another solution its an very urgent for me

  23. Charon says:

    It works fine and I was able to save the host-file after turning norton off.

  24. Lars says:

    Vista protects the hosts file and it is perfectly sane and valid that it does so.

    To edit it you must do son as administrator:
    Right click the shortcut of your favorite editor such as Notepad as select Run as Administrator.
    From within the editor, open the hosts file (or drag and drop it into the editor).
    Now you are able to save changes to it.

    • mmas says:

      you just said what everybody else did, but it just doesn’t seem to work for me. whatever I do, run as administrator or not, every time I receive the same stupid message -make sure the path and filename are correct. Impossible to save

  25. Haytham says:

    Thanks a lot!

  26. SADIK NAUFAL says:


  27. Rick Valden says:

    Thanks alot for this info. Good stuff! Really helped me do something I couldn’t figure out.

  28. Rick Grant says:

    How do I block the Vimax ads on a Mac???
    “ b1.adv.net” where do I copy this on a Mac???
    Thanks for any help??!!

  29. I can’t find etc in System32 folder.

  30. Alvin says:

    It works! Thanks man!

  31. mikey says:

    This is the only method that actually worked for me. The norton site is useless.


  32. Leishtek says:

    Kind of plain vanilla (some PICTURES would have helped, guys…) but does the trick. Question is, will XP7, er i mean Windows 7 *wink* change the place the HOSTS file is stored. I hate having to remember 3 operating systems. They should keep it in the same darn place.

  33. tessa says:

    thank you! this information was quite useful.

  34. Drew says:

    I can’t get past this error…

    “Cannot create the C:\Windows\System32\drivers\etc\hosts file. Make sure that the path and file name are correct.”

    It keeps wanting to add a .txt extension like I can’t save a file without an extension. I’m running notepad as administrator and I tried disabling my Norton AV. Nothing is working. Argh!

  35. Drew says:

    It is already there. I open up Notepad as admin and then I open up that hosts file no problem. I make my changes but then when I save it won’t let me do it without an extension for some reason.

    I wound up letting it save as .txt and then i just browsed back to that directory, renamed the original hosts file as a backup, then removed the .txt extension from the new one I saved and now I’m up and running.

  36. Gurmeet Singh says:

    This is good.

  37. Alper says:

    Very useful information and very neatly described. Thanks!

  38. Daniel says:

    I was having issues and finally realized that my hosts file was set to read-only… once I cleared that flag, then I was able to edit it (as admin.)

  39. Forest Marie says:

    For The Guys Who Are Getting The “Cannot Create …”

    This is not a Vista issues. A lot of package and in my case – Spybot Search & Destroy – not only add entries to your hosts files, but they also set it to read only mode…

    Right click and uncheck read-only as Daniel said and you will be able to edit it finally!

  40. mike says:

    this is what i have for a hosts file.

    # Copyright (c) 1993-2006 Microsoft Corp.
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a ‘#’ symbol.
    # For example:
    # rhino.acme.com # source server
    # x.acme.com # x client host localhost
    ::1 localhost

    since its just an example im pretty sure nothing i do is gonna make a difference. anyone wanna give me a hand?

  41. Ajeet says:

    Thanks dear. You solved my problem.

  42. Cholla says:

    Thanks!It was the only one way for my Vista.

  43. farie says:

    thanks!!luv u all

  44. Neha says:

    thanks your post really helped me!

  45. Thanx a lot to solve my problem of editing the host administrator file

  46. Brenda says:

    Thank you so much. I went from XP to Windows 7 and this administrator crap was driving me crazy trying to edit the host file.

  47. alan says:


  48. loot says:

    This has been a superb post

  49. gilgain says:

    I had to add a bothersome popup web page while using megavideo.com to watch tv.
    I discovered a couple of steps necessary to overcome Vista and S&D’s security messures of safety.
    1st. Make a copy of the file for backup.
    2nd. I needed to cut/paste the file into another location…I did a temp folder on the desktop. (see step 4 below on administrator rights)
    3rd. Do a properties on the file to verify it is not “read only” file.
    4th. Open it with Notepad…administrator or not…you will be prompted for a password if req’d. The profile I was using to modify the file does not have administrator rights, but Vista allows it with a pop-up dialog asking for it.
    5th. When finished editing the file and saving it…do a properties on it to make it “read only” again, and then cut/paste it back into the original folder.
    6th & final. I believe the computer must be restarted to load the host file into the system with the changes made.

    If successful, the drinks are on you. Cheers

  50. Maxin says:

    Cool, thanks my great friend !

  51. Javier says:

    Thank you this works just fine

  52. Tommy says:

    No luck on my part. Nothing I do is working, I ran notepad as administrator, I un-ticked read only, I even allowed full control for my user. It’s still not letting me save, copy, or rename it.

  53. Kelsey says:

    This is very helpful but I have a problem. I don’t have a hosts file. I have “hostbackup” “Imhosts.SAM” “networks” “protocol” and “services”

    If I change hostbackup will it still work?

    • PopJim says:

      Kelsey: On Vista & Win7 the hosts file may be named “hosts” OR “lmhosts”. The “.SAM” suffix designates a SAMPLE of the file. If you
      try to save a notepad file as “hosts” when there is already a
      “lmhosts” file, notepad will say “file already exists”. If you then
      save as “lmhosts” instead, it will work fine (may have to remove
      a ‘read only’ attribute if set)…..

  54. megkar says:

    thank you man! you’re very helpful….

  55. sky says:

    Hi all,
    I use windows 7 platform. I tried those ways to run as administrator on my Notepad, still cannot save it to replace the hosts file. What is the extension on this file? Or is somewhere wrong with my computer?
    I have second question: if i deleted all the content, just leave localhost over there, is that will affect my other computer system?
    Thanks in advance!

  56. Brock says:

    i went to etc and there is no host file ???
    plz help

  57. Thais says:

    Helped me a loooot!!!!

    I figured opening it with administrative privileges would do the trick, but I was trying to directly open the “hosts” file and there was no option to do that with a rigt-click.

    I got tired guessing and asked oncle Google for once; I´m glad to click on your site, very helpful.

  58. NeShae says:

    Ok so I’ve done everything that everyone has posted. When I run my notepad as an administer and try to save the host file it says “you require permission from SYSTEMS to make changes to this file.” Can anyone help me because it seems like I’m the only one getting this message error.

  59. Brian John says:

    First of all I like to read the comments posted to problems/situations posted online, whether I have a problem or not. I find it a good system of enhancing my knowledge. I am eternally grateful for all the assistance that pours in from all quarters, as it demonstrates a willingness to help. But I sometimes find the mass of information confusing. For instance the person giving the advice knows the solution and should think it out carefully and then present it chronologically so that it becomes a snap to follow. Also, sometimes it is necessary to explain the obvious because lots of people are unfamiliar with the terms or may not be as machine savvy as you may think. The final comment is that sometimes with all the knowledge that we possess we sometimes overlook the question that is being asked then you find that the offered solutions are a bit far-fetched or even convoluted.

Leave a Reply

Subscribe to this guide's comments RSS feed.

Microsoft Windows is a registered trademark of Microsoft Corporation. Microsoft Corporation in no way endorses or is affiliated with MAXIMUMpcguides.com. All other products mentioned are registered trademarks of their respective companies. MAXIMUMpcguides IS NOT RESPONSIBLE for any damage or data loss to your computer from using this web site. All information on MAXIMUMpcguides is provided on an AS IS basis with NO WARRANTIES.

Copyright 2006-2019 Brent Trahan. All rights reserved.