The Domain Proper noun System (DNS) is the key to locating a website on the Internet. With and then much at pale, making changes to your DNS records can be a nerve-wracking experience.

Fortunately, there is a way to test DNS-related changes without editing your live records. Past modifying your local hosts file, y'all can preview how your domains will role on a new server without putting your alive site at adventure.

In this post, we'll explore what hosts files are and share some reasons why you may desire to alter them. We'll and then testify you how to edit hosts files on Windows 10. Let'southward become started!

An Introduction to the Hosts File

A hosts file is a local plain text file that maps your server or hostnames to Internet Protocol (IP) addresses. Every time Windows 10 connects over a network using a hostname, it'll refer to the hosts file. If Windows finds an entry in this file, then information technology'll contact the specified server.

If it doesn't observe a relevant hostname, Windows 10 volition resolve the hostname using a Domain Proper noun Service (DNS). This is the process used to obtain the server IP accost behind a domain name.

Each hosts file entry has its own line, with the numerical IP address, a space or a tab grapheme, and finally the hostname or domain. Let's wait at an case of a hosts file entry:

120.0.0.0 example.com #Example

In the above instance, the first section denotes the IP address where this request will be redirected to (120.0.0.0). The second section designates the location that we want to redirect a asking from (example.com). The final department specifies a comment for this entry. We're using a hashtag to tell Windows 10 to ignore the annotate when reading the local hosts file.

Subsequently adding the domain information, your arrangement volition resolve to the IP address you specified. In the above example, we're associating the domain name example.com with the IP address 120.0.0.0.

Information technology's worth noting that some software employs its own techniques to look up hostnames. This means at that place's always a risk that it may ignore the hosts file completely.

DNS is the cardinal to locating a website. πŸ”‘ With and so much at pale, making changes to your DNS records can be a nervus-wracking experience. 😰 Acquire how to safely alter your host files in this guide πŸ‘‡ Click to Tweet

What Happens When Y'all Modify a Hosts File?

When you modify your hosts file, it causes your local machine to expect directly at the IP address specified by you lot. For example, if you lot wanted to indicate mywebsite.com to the IP address ane.2.3.4.5, yous'd add together the following:

ane.2.iii.four.5 mywebsite.com

Now, every time you try to visit mywebsite.com, you lot'll find yourself at 1.2.iii.four.5 instead. Past editing your hosts file, you can override the DNS for a domain on your specific machine but.

In this mail service, we'll exist focusing on opening your hosts file and adding individual entries. Still, it is also possible to replace this file entirely. This tin can exist an easy way to block malicious or spammy websites in bulk. There are fifty-fifty sites that have published prepare-made lists of IP addresses associated with advertisements, hijackers, page counters, and other unwanted connections.

Y'all can download i of these pre-prepared lists and copy/paste its contents into your existing hosts file. Alternatively, you lot might replace your native hosts file with the newly-downloaded file. If you do opt for the latter, then we recommend keeping a copy of your original file, just in case you run across any strange behavior with its replacement.

Why You May Want To Change the Windows 10 Hosts File

Y'all tin can use your hosts file to test DNS-related changes without having to alter your DNS records. For example, imagine you've migrated to a new server. Earlier updating your DNS settings, it'south a skilful idea to verify how your domains will look and office on this new server.

Withal, if you enter your current domain name, then information technology'll resolve to your old server. In this scenario, you tin can modify your hosts file to point the domain to the new server's IP.

This file can also help exam how your website looks on a dissimilar server when your DNS hasn't propagated yet. At Kinsta we provide a temporary URL (sitename.kinsta.cloud), but this cannot mimic everything. For example, by default, a CDN won't work on a temporary URL.

You can as well use the hosts file to cake certain websites. This can be useful for employers who want to ensure that their staff isn't wasting fourth dimension on unauthorized sites such equally Facebook, Twitter, or YouTube.

While there are fewer technical ways to block access to unauthorized websites, many of these methods are relatively easy to reverse. For example, a tech-savvy child may have picayune problems bypassing parental controls, but modifying the hosts file requires a higher level of technical knowledge.

You might accept this a step farther and cake all websites that serve up advertisements. If you map the addresses of all the major ad providers to an unused internal IP address, then Windows ten will be unable to resolve these addresses. You can then enjoy the spider web, advertizing-free.

Finally, some malicious third parties may gear up up redirects by altering your hosts file. This is known equally a hosts file hijack. If you lot're encountering strange redirects, then it may be worth checking your hosts file for suspicious entries.

How To Brand Firefox Honor the Windows ten Hosts File

If yous're using Firefox for Windows, then Mozilla's browser resolves IP addresses slightly differently compared to the other major browsers. Past default, Firefox uses DNS-over-HTTPS (DoH).

This is a protocol for performing remote DNS resolution via HTTPS. With this setting enabled, Firefox will apply the DOH server as the primary proper name resolver, rather than checking your local hosts file or DNS resolver.

As a upshot, the website displayed will always point to the IP address that the Cyberspace deems administrative for that domain. Even if y'all edit your hosts file, your changes won't have whatsoever effect if the DoH server returns a working IP address.

At that place are plenty of cracking spider web browsers that are compatible with Windows ten and that honor the hosts file out-of-the-box. However, if yous want to stick with Mozilla Firefox, yous can ever disable DoH.

To first, select the Menu push button in the Mozilla Firefox browser and become to Settings.

Select the Menu button in the Mozilla Firefox browser and go to Settings.
Find the menu button and click on Settings.

In the subsequent tab, make sure General is selected. Then, scroll to the Network Settings section and click on Settings.

Find network settings in Firefox
Network Settings in Firefox

In the popup that appears, ringlet to Enable DNS over HTTPS. Then, uncheck the accompanying box.

Scroll to Enable DNS over HTTPS
Scroll to Enable DNS over HTTPS

To salve your changes, click on OK and so exit this window. From this point onwards, Firefox will honour whatsoever custom addresses that you add to your Windows 10 hosts file.

How To Edit Your Windows 10 Hosts File (In 3 Steps)

There are many reasons why you might need to edit this important file. Regardless of whether yous desire to block advertising networks, verify a new domain, or perform other DNS-related tests, the process will be exactly the aforementioned.

Allow's await at how to add together custom addresses to the Windows ten hosts file.

1. Notice Your IP Address

Frequently, you lot'll want to change how Windows 10 resolves the IP address of a site that y'all own. To brand this modification, yous'll need to know your website's IP address.

If yous're a Kinsta customer, you lot tin retrieve this information easily using the MyKinsta dashboard.

The MyKinsta dashboard
The MyKinsta dashboard

Find the domain that yous want to work with and click on it. On the next screen, you'll find some information about this domain, including your IP accost.

Click on the "Sites" option in MyKinsta
Click on the "Sites" choice in MyKinsta

Alternatively, y'all might want to modify how Windows 10 resolves a third-party IP address. You can retrieve whatsoever website's IP address using tracert.

Subscribe Now

Tracert is typically used as a network diagnostic tool to help resolve network connectivity issues. However, yous can also use it to trace the paths a data parcel takes from its source to its destination, which will reveal the IP accost of the destination website.

To launch tracert, click on the Start icon, then type control prompt into the search bar.

Type command prompt into the search bar
Type command prompt into the search bar

When the command prompt icon appears, give it a click. In the subsequent window, type tracert followed past the URL of the website in question, for example:

tracert website.com

Adjacent, press the Enter key on your keyboard. The command prompt volition so display the IP accost of website.com in a bracket alongside the URL.

2. Run Notepad as an Ambassador

In Windows XP and before, editing your hosts file was relatively straightforward. You could simply add together an exception to your antivirus, open the hosts file in the Notepad awarding, and then make your changes.

However, Windows ten added some security measures to prevent users from accidentally modifying this important file. This makes sense, equally editing the hosts file could potentially make your favorite websites inaccessible. In the worst-case scenario, it might even make the Net unusable on your machine.

In Windows 10, the hosts information is stored in a plainly text file in the internal System32 folder. While you should have no problems opening this file, when you try to save your edits y'all might come across the following error: "You lot don't have permission to save in this location. Contact the administrator to obtain permission".

If yous desire to relieve your changes, you'll need administrator admission. The quickest fashion to gain this is to use a text application that has elevated privileges. In this post, we'll be using Notepad.

To start, printing the Windows key and type Notepad into the search field.

Search for the Notepad app
Search for the Notepad app

Side by side, right-click on Notepad and select Run as Ambassador. Windows x will at present ask whether you want to allow this awarding to make changes to your device. Select Yes.

Select Run as Administrator
Select Run as Administrator

This launches a privileged instance of the Notepad awarding. Note that y'all may be asked to enter an administrative password in gild to re-authenticate yourself.

3. Make Your Changes

Once y'all have Notepad open in ambassador fashion, yous're prepare to edit the hosts file. In the Notepad toolbar, select File > Open.

Select File and then Open in the Notepad toolbar
Select File and so Open in the Notepad toolbar

Then, navigate to C:WindowsSystem32driversetchosts. Alternatively, you can copy/paste this file path into the address bar then press Enter.

If you don't see the hosts file in your /etc directory, y'all may need to change the file filter type. In Notepad, open the File name dropdown and choose All Files.

Open the File name dropdown and choose All Files
Open the File name dropdown and choose All Files

One time you lot take the hosts file in your sights, you're prepare to edit. If this is your showtime time opening this file, you'll see some text describing the file'due south purpose and how to brand modifications, for example:

          # This file contains the mappings of IP addresses to host names. Each  # entry should be kept on an private 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 i  # space.        

You can now add your custom IP accost and hostname to the finish of this file. If you're adding multiple entries, recall to place each entry on a split line. Once you're happy with your changes, you can save and shut the hosts file.

To make sure your computer recognizes your edits, it's a good idea to affluent the DNS cache. If you don't currently have a command prompt window open, click on the Windows push and search for control prompt. In the subsequent window, type the following:

          ipconfig /flushdns        

To affluent the DNS enshroud, press the Enter central. Once this procedure is complete, Windows 10 should be using your new hosts file settings. Alternatively, restarting your computer should have the same result.

How To Lock Your Hosts File on Windows 10

Past default, y'all cannot edit the hosts file without administrator privileges. Withal, it isn't incommunicable to learn these privileges, peculiarly for tech-savvy individuals.

If you're worried about unauthorized edits, you can add an extra layer of security to your hosts file. For example, y'all might exist using the hosts file to prevent staff from accessing social media sites and you lot're concerned near them bypassing your restrictions. You might also be worried about hosts file hijack attacks.

In these scenarios, you might want to consider locking your hosts file. While this security precaution isn't bullet-proof, it will dissuade third parties from tampering with the file.

To lock your hosts file, navigate to C:WindowsSystem32driversetchosts. Then, correct-click on the file and select Properties.

C:WindowsSystem32driversetchosts
C:WindowsSystem32driversetchosts

In the Properties window, mark the hosts file as Read-only. This will lock the file and prevent anyone from modifying information technology.

If you want to remove this lock at any point, simply navigate back to the Properties window. You can and so remove this Read-only restriction.

How To Reset Your Windows 10 Hosts File

You can always remove individual entries from your hosts file. Only open the file in Notepad and delete the line in question.

Still, sometimes you may need to revert your hosts file to its original state. For example, you might have made multiple adjustments to your file and don't particularly want to unpick each of these changes manually. You lot may as well be encountering strange redirects, which suggests that your hosts file has become corrupted.

To reset your hosts file back to its original country, open your File Explorer. In the accost bar, either type or re-create/paste the post-obit:

          %systemroot% system32driversetc        

And so, press the Enter cardinal on your keyboard. At this point, we recommend renaming your original hosts file. This file volition so serve equally a fill-in, just in example you encounter whatsoever problems with your new hosts file.You may be required to take ownership of this file first, depending on how privileges are configured on your reckoner.

The next stride is creating a new default hosts file. To accomplish this, create a text file in the %WinDir%system32driversetc directory, and name this file hosts.

You can now copy/paste the text from Windows' default hosts file, which is provided by Microsoft:

          # Copyright (c) 1993-2009 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 exist kept on an individual line. The IP accost should  # be placed in the first column followed by the corresponding host name.  # The IP accost and the host proper name should be separated by at to the lowest degree 1  # space.  #  # Additionally, comments (such as these) may be inserted on individual  # lines or post-obit the automobile proper name denoted past a '#' symbol.  #  # For case:  #  # 102.54.94.97 rhino.peak.com # source server  # 38.25.63.10 x.acme.com # x client host  # localhost name resolution is handled within DNS itself.  # 127.0.0.ane localhost  # ::1 localhost        

Save this file. As always, y'all may demand to reset your computer or flush your DNS enshroud in order for these changes to take upshot.

Worried near testing DNS-related changes? πŸ˜…Don't sweat it. πŸ˜„ Learn how to use your local hosts file to preview edits without putting your site at risk πŸ‘‡ Click to Tweet

Summary

Making changes to your DNS records tin feel like a stressful endeavor. However, equally we discussed in this commodity, yous can safely examination your local hosts file without putting your live records at risk. In Windows 10, you can do this by finding your IP address, running Notepad equally an administrator, then making your changes.

If you enjoyed this tutorial, then you'll love our support. All of our hosting plans include 24/7 support from our earth-class WordPress developers and engineers. We can provide the assist you demand to succeed, regardless of whether it's ii:00 a.grand. or 2:00 p.m.


Save time, costs and maximize site performance with:

  • Instant help from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • Global audience achieve with 29 data centers worldwide.
  • Optimization with our built-in Application Performance Monitoring.

All of that and much more, in one plan with no long-term contracts, assisted migrations, and a 30-day-money-back-guarantee. Check out our plans or talk to sales to notice the plan that's correct for you.