PDF download Download Article
Easily find and edit the Windows hosts file like a pro
PDF download Download Article

The Windows hosts file is a system file you can edit to map hostnames or servers to IP addresses. Most people won't ever need to edit this file, but sometimes, certain apps and services require making some changes, or you may need to add lines to the host file to block certain apps or domains. This wikiHow guide teaches you how to open, edit, and save the Windows Hosts file using Notepad and the PowerToys Hosts File Editor. We'll also help you troubleshoot problems with your hosts file if you don't get the expected results.

Edit the Hosts File on Windows: Quick Steps

  1. Open Notepad as an administrator.
  2. Go to File > Open.
  3. Navigate to c:\Windows\System32\Drivers\etc.
  4. Select All Files from the drop-down menu.
  5. Select the hosts file and click Open .
  6. Add any new lines below the current last line.
  7. Go to File > Save .
Section 1 of 3:

Editing the Hosts File in Notepad

PDF download Download Article
  1. This opens the Windows menu and the search bar.
    • To edit the hosts file in Windows, you need to open Notepad as an administrator . This means you must be an administrator of this PC to edit the hosts file.
  2. Don't click anything yet—just type the word and wait for the search results to appear.
    Advertisement
  3. A menu will expand.
  4. This opens Notepad as an administrator.
    • You may have to click Yes on the security warning to open Notepad as an administrator.
  5. This opens your file browser.
  6. The hosts file is usually located at c:\Windows\System32\Drivers\etc . You can paste that path into the bar at the top of the window and press Enter to go there. Don't worry–you won't see any files at first, but they are there.
    • If Windows is installed on a different drive letter (e.g., on your D: drive instead of C:), replace the C: in the path with the correct drive letter.
  7. It's the menu toward the bottom-right corner of the window. You should now see a handful of files, including the hosts file.
  8. The hosts file is now open for editing.
  9. Now that the file is open, you can add lines to the file or remove lines you don't need.
    • When you add a line to the hosts file, you'll want to enter the IP address first, followed by the domain name you're mapping it to. Separate the two with a space or a tab, and keep each entry on its own line. [1]
    • If you're editing the host file to block a website , the IP address you'll enter is 127.0.0.1 . For example, to block Facebook, you'd enter 127.0.0.1 facebook.com .
      • Don't add "https://" or any other protocol before the domain name.
    • Create a new line for each IP address and domain mapping you need to add to your hosts file.
    • Lines that begin with a hash symbol # are considered comments, meaning they are inactive. If you want to remove a line in the hosts file, you can either delete it, or just type a # before it to comment it out. This way, you can easily reactivate the mapping if you change your mind later.
  10. This saves your changes to the hosts file.
    • If you are unable to save the file this way, try this:
      • Click the File menu and select Save as .
      • Select All Files from the "Save as type" menu.
      • Click Save .
  11. Advertisement
Section 2 of 3:

Using the PowerToys Hosts File Editor

PDF download Download Article
  1. PowerToys now offers a utility that makes it easy to edit your hosts file in Windows. [2] If you don't want to mess around with your hosts file in a text editor, the Hosts File Editor is a great way to edit your Windows hosts file. To install PowerToys:
    • Go to the PowerToys release page on GitHub.
      • The most current version of PowerToys is at the top of the page.
    • Click the download link for the version you want to install and select Save .
      • For example, if you want to install PowerToys only for yourself, not every user on your computer, and you have an Intel CPU, select the download link for "Per user—x64."
      • If you have an ARM processor and want to install PowerToys for every user on your computer, select the downloader for "Machine wide - Arm64".
    • Once downloaded, double-click the installer in your default downloads folder.
    • Check the box to agree to the terms and click Install .
    • Click Close once the installation is complete.
  2. PowerToys comes with a ton of cool new tools, but unfortunately, it enables them by default, and they might interrupt you while you're trying to edit your hosts file. For now, we'll disable the other PowerToys so you can stay on task instead of wrestling with changes to how your mouse and desktop behave. Here's what to do:
    • If PowerToys doesn't open on its own, open it from the Start menu.
    • Click Open Settings on the Welcome screen.
    • Turn off the toggle switches next to all options EXCEPT "Hosts File Editor."
  3. Now that everything else is turned off (and you should come back and check out the other PowerToys later), click Launch Hosts File Editor to open the editor.
    • When prompted, click Yes and then Accept to confirm that you want to edit the hosts file.
  4. It's at the top-left corner. If you need to add an IP address and domain/hostname combo to your hosts file, you'll do it here.
  5. For example, if you're using the Hosts File Editor to block a website, you'll enter 127.0.01 here.
  6. For example, if you want to be taken to the IP address you entered each time you access facebook.com, you'd enter facebook.com here. Don't add "https://" or any other protocol before the domain name.
    • If you're blocking a website, it's a good idea to block both the domain name and the domain name with "www" at the beginning, and any other subdomains you know. For example:
      • 127.0.0.1 domain.com
      • 127.0.0.1 www.domain.com
      • 127.0.0.1 login.domain.com
    • If you were instructed to enter more than one hostname or domain name, separate them with single spaces.
    • If you'd like, you can add a comment to the "Comment" field that describes this entry. For example, if you're adding a line to block ads from a specific application, you might type that application's name here.
  7. Once added, the line will be active in your Windows hosts file.
  8. Each entry you see on the main screen is taken directly from your Windows hosts file, which is usually at c:\Windows\System32\Drivers\etc . You'll see there's a toggle switch next to each line.
    • If the toggle switch next to a line in your hosts file is in the off position, that rule is inactive, so it won't be used.
    • You can easily disable a rule in your hosts file by toggling off its switch.
    • If you'd rather delete something from your hosts file entirely, click the trash can icon.
  9. Advertisement
Section 3 of 3:

Why isn't my hosts file working?

PDF download Download Article
  1. If the change you made to your hosts file isn't active yet, you may need a quick DNS flush . Here's what to do:
    • Open the Command Prompt as an administrator. To do this:
      • Press the Windows key and type cmd .
      • Right-click "Command prompt" and select Run as administrator .
    • Type ipconfig /flushdns and press Enter .
  2. Clear your web browser cache. If you added something to your hosts file that's supposed to block a website or direct you to a different IP address when you enter a hostname or domain name in your web browser, the old page may still be cached. Just clear your cache and try loading the site again.
  3. If you're using Chrome, this trick will clear Chrome's DNS cache, which could make the changes you made in your hosts file take effect in Chrome.
    • Type chrome://net-internals/#sockets into your address bar and press Enter .
    • Click Flush socket pools .
    • Click the DNS tab in the left panel.
    • Click Clear host cache . [3]
  4. The hosts file is mainly for mapping a domain name to an IP address, similar to how DNS works on a larger scale. If your goal is to block a website, block an ad domain, or similar, the hosts file won't always be effective–not all applications prioritize the hosts file over DNS, and sometimes IP addresses and domain names change. It's better to use a website-blocking or ad-blocking tool to get the job done.
  5. Advertisement

Video

Expert Q&A

Ask a Question
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Article Summary X

      1. Open Notepad as an administrator.
      2. Go to File > Open .
      3. Go to c:\Windows\System32\Drivers\etc.
      4. Select All Files from the drop-down menu.
      5. Select the hosts file and click Open .
      6. Make your changes.
      7. Click File > Save .

      Did this summary help you?
      Thanks to all authors for creating a page that has been read 89,984 times.

      Is this article up to date?

      Advertisement