Skip to content
OnMSFT.com
  • Home
  • About
  • Contact
  • Windows
  • Surface
  • Xbox
  • How-To
  • OnPodcast
  • Edge
  • Teams
  • Gaming
Menu
  • Home
  • About
  • Contact
  • Windows
  • Surface
  • Xbox
  • How-To
  • OnPodcast
  • Edge
  • Teams
  • Gaming
  1. Home
  2. How-to
  3. How to modify your hosts file in Windows 10 (and why you might want to)

How to modify your hosts file in Windows 10 (and why you might want to)

James Walker James Walker
October 15, 2018
4 min read

Photo of Windows 10 hosts file on desktop\n

\n

Modify your hosts file in Windows 10

\n

Here’s how you can modify Hosts files in Windows 10, and map domain names to server IP addresses of your choice.

\n

    \n

  1. Open Notepad with administrator privileges
  2. \n

  3. Browse to C:\\Windows\\System32\\drivers\\etc\\hosts (Or paste this into the address bar)
  4. \n

  5. Open the file
  6. \n

  7. Make your changes
  8. \n

\n

\n

Applies to All Windows 10 Versions

\n

\n

Windows 10 still retains the old computing standard of having a hosts file for rudimentary hostname mapping. In simpler terms, the hosts file provides a mechanism to map domain names (such as “onmsft.com”) to server IP addresses of your choice.

\n

Windows refers to the hosts file each time it connects over a network using a hostname. If it finds an entry for the hostname in the hosts file, it will contact the server specified in the file. Otherwise – and in the vast majority of cases – it will resolve the hostname using DNS (domain name service), which is the process used on the Internet to obtain the server IP address behind a domain name.

\n

While it may sound technical, the hosts file is a really simple approach to network routing – and it’s easy to add your own entries. To get started, you just need to open the file. It resides in Windows’ internal “System32” folder, so to save your edits you’ll need administrator access.

\n

\n

The quickest way to open the file is using Notepad with administrator privileges. Search for Notepad (press the Start button and type its name) and right-click the app to display the context menu. Click “Run as administrator” to launch a privileged instance of the app. Note you may need to reauthenticate yourself or get an administrator’s password if you’re not already logged in as one.

\n

\n

With Notepad open in administrator mode, you’re ready to open the file. Click File > Open and browse to the file at C:\\Windows\\System32\\drivers\\etc\\hosts (you can copy and paste this into the address bar at the top of the Open window). If you do browse through the folders graphically, remember to change the file type filter to “All Files” so the hosts file shows up.

\n

Now you’re ready to edit the file. If you’ve never opened the hosts file before, all you’ll see is a short section of text describing its purpose and how to make edits. The introduction provides a useful overview of how the file is structured, but we’ll cover the basics here.

\n

\n

The hosts file is a simple mapping of IP addresses and hostnames. Each entry goes on a newline, with the IP address (that’s the numerical address) first, followed by a space or tab character and then the hostname (or domain). You can add comments to the file by placing a “#” character at the start of the line – this will make Windows ignore the line when reading the file.

\n

Therefore, if you want to point “microsoft.com” to the IP 1.2.3.4, you’d write “1.2.3.4 microsoft.com” on a new line. Each time you try to visit microsoft.com, you’ll find yourself instead at the (non-existent) 1.2.3.4 website.

\n

\n

At this point, you may be wondering why you’d ever need to edit the hosts file. While it is more useful to technical users, there are also a few more general cases in which it might have value. One example is if you wanted to block a certain website, for example Google. By adding an entry for “google.com” to the hosts file, you can force Windows to point the address to a different location – so users won’t be able to visit the site.

\n

To achieve this example, add a line such as “0.0.0.0 www.google.com” to the file. Save the file and try and visit Google in your browser. You should find the site fails to load.

\n

\n

Remember that this is a far from infallible way to block a site – another user could simply reverse the hosts file edit themselves. In addition, some software may employ its own techniques to lookup hostnames which might ignore the hosts file.

\n

One far more realistic application of the hosts file is to block websites which serve up ads or spyware. Although we won’t be listing any here, if you map the addresses of prominent ad providers to an unused internal IP address (such as 127.0.0.1), you’ll suddenly be browsing an ad-free internet – in every browser.

\n

Windows will resolve the ad URLs to an address that no longer points to the providers’ servers. Just remember that every address you add must be the hostname only (example.com), not the full web address (http://www.example.com).

\n

That’s all about the hosts file. While you’re unlikely to use it outside of a development or network environment, it does have practical applications which could be of use to every PC consumer. You should also know that the hosts file also exists on Mac and Linux systems with the same syntax, albeit in a different location.

\n\nFurther reading: howto, Windows 10, Windows 10 Howto

Share this article:
Tags:
howto Windows 10 Windows 10 Howto
James Walker
Written by

James Walker

I'm a web developer and technology journalist with a particular interest in Microsoft innovations. I'm the founder of Heron Web (heron-web.com), a UK digital agency for web design and development. When I'm not working, I'm a PC gamer and passionate transport enthusiast.

Previous Article Microsoft to disable outdated TLS 1.0, 1.1 for Edge and IE early next year Next Article Microsoft test new Cortana UI for Android and iOS with v3.0 beta

Related Articles

43 Microsoft Edge keyboard shortcuts to remember for stylish and speedy web surfing

October 31, 2023

How to use accessibility features in Microsoft 365 like Narrator, Read aloud and Voice Search easily

October 30, 2023

How to use Windows Backup on Windows 11 for efficient data protection

October 26, 2023

Leave a Comment Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • PowerToys 0.75 released; Environment Variables editor is here
  • Former Halo developer Bungie announces layoffs in wake of game delays
  • Siemens and Microsoft partner to bring GenAI to industries worldwide
  • 43 Microsoft Edge keyboard shortcuts to remember for stylish and speedy web surfing
  • Here is what’s coming to (and leaving) Xbox Game Pass soon

Recent Comments

No comments to show.

Archives

  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010

Categories

  • Announcements
  • Deals
  • Developer
  • Editorial
  • Feature
  • Feature stories
  • Hero-post
  • Hotdeals
  • How-to
  • Latest news
  • Microsoft / office 365
  • News
  • Office 365
  • Onpodcast
  • Opinion
  • Our featured post
  • Polls
  • Review
  • Reviews
  • Videos
OnMSFT.com

OnMSFT.com covers Microsoft news, reviews, and how-to guides. Formerly known as WinBeta, we have been your source for Microsoft news since 1998.

Categories

  • Windows
  • Surface
  • Xbox
  • How-To
  • OnPodcast
  • Gaming
  • Edge
  • Teams

Recent Posts

  • PowerToys 0.75 released; Environment Variables editor is here
  • Former Halo developer Bungie announces layoffs in wake of game delays
  • Siemens and Microsoft partner to bring GenAI to industries worldwide
  • 43 Microsoft Edge keyboard shortcuts to remember for stylish and speedy web surfing
  • Here is what’s coming to (and leaving) Xbox Game Pass soon

Quick Links

  • About OnMSFT.com
  • Contact OnMSFT
  • Join Our Team
© 2010–2026 OnMSFT.com LLC. All rights reserved.
About OnMSFT.comContact OnMSFT