Key Takeaways
On Windows, motorboat Notepad (or different matter editor) arsenic Administrator. Open nan hosts file, which is located nether C:\Windows\System32\drivers\etc. On Mac and Linux, edit nan /etc/hosts record utilizing your matter editor arsenic prime — beryllium judge to motorboat nan editor pinch sudo.
Occasionally you whitethorn request to edit nan hosts record connected your machine. Your big record mightiness person been edited maliciously successful an attack, aliases arsenic a prank. Alternatively, you whitethorn conscionable want to power entree to definite websites aliases power web traffic.
What is nan Hosts File Used For?
The hosts record was utilized to resoluteness big names for decades earlier the DNS system was implemented, since measurement backmost successful nan ARPANET days. Since they were utilized to adjutant successful web sanction resolution, hosts files grew to go monolithic documents.
Microsoft, Apple, and different operating strategy developers person kept nan hosts record around, which is why it varies very small betwixt Windows, macOS, and Linux. The syntax stays mostly nan aforesaid crossed each platforms. Most hosts files will person respective entries for loopback. We tin usage that for nan basal illustration for nan emblematic syntax.
The first portion will beryllium nan location to redirect nan reside to, nan 2nd portion will beryllium nan reside that you will want to redirect, and nan 3rd portion is nan comment. They tin beryllium separated by a space, but for easiness of reference are typically separated by 1 aliases 2 tabs, aliases nan balanced magnitude of spaces. The wide format is:
(IP Address) (URL) #(Comment)As a circumstantial illustration for nan loopback address:
127.0.0.1 localhosts #loopbackNow let's look astatine accessing nan hosts files successful different operating systems.
Editing nan Hosts File connected Windows 10 aliases Windows 11
The hosts record is still coming successful nan latest and top from Microsoft — Windows 10 and Windows 11 — contempt being ancient by machine standards. It isn't utilized overmuch successful in modern Windows networking, however.
The Windows hosts file, for illustration different files that tin beryllium recovered successful nan Windows folder, is protected. You request administrative privileges to move, edit, aliases delete nan file.
You tin usage immoderate plain matter editor you want to modify nan hosts file, nevertheless Notepad is perfectly capable for nan task. You don't request to spell download different 1 conscionable for this job.
Hit nan Start button, type "notepad" into nan search, and past right-click it and deed "Run arsenic Administrator."
Click connected "File" successful nan apical near corner, deed "Open," and past navigate to nan Windows hosts file's location:
C:\Windows\System32\drivers\etcMake judge to alteration nan prime to "All Files (*.*)" alternatively than "Text Documents (*.txt)." The hosts record doesn't person a record extension, truthful it won't show up if you're only displaying matter documents. After you alteration that setting, find nan "hosts" fileand click open.
You tin past edit nan hosts record nevertheless you'd like. There are a fewer evident things to do pinch it, for illustration block aliases reroute net traffic.
Editing nan Hosts File connected Windows 8 aliases 8.1
Editing nan hosts record connected Windows 8 and 8.1 is fundamentally nan aforesaid arsenic Windows 10 aliases 11.
Just hunt for Notepad, right-click connected Notepad successful nan hunt results list, and past take "Run arsenic Administrator.
Once you've opened Notepad, click "File" successful nan apical right, click "Open," and past navigate to nan /etc/ folder:
C:\Windows\System32\drivers\etc\hostsYou'll beryllium capable to edit nan hosts record for illustration you would immoderate different file. You tin usage it to artifact entree to websites, if you want.
If you get an correction notifying you that you don't person permission, you didn't really tally Notepad arsenic administrator.
Windows 7
Accessing nan hosts record successful Windows 7 is nan aforesaid arsenic connected newer versions of Windows. You request to tally Notepad arsenic administrator, navigate to nan hosts file, and past unfastened it up.
There are a fewer ways you tin do this. The first is to find Notepad, right-click it, deed "Run arsenic Administrator," and past navigate to nan hosts file. It is located at:
C:\Windows\system32\drivers\etc\Alternatively, you tin deed Windows+R to unfastened up a Run window, and past participate nan pursuing command:
notepad c:\windows\system32\drivers\etc\hostsThe bid will tally Notepad arsenic administrator and automatically unfastened nan specified file.
Once notepad is unfastened you tin edit nan file. In this illustration we will artifact Facebook. To do this conscionable participate successful nan pursuing aft nan # mark.
0.0.0.0 www.facebook.comNow that you person edited your Hosts record make judge to prevention it.
Now announcement if we effort to entree Facebook successful IE we can't get to nan page.
We besides were not capable to get to it successful Google Chrome... (check notes astatine nan end). Also for much info connected editing your Hosts file, cheque retired The Geek's article connected how to create a shortcut to quickly edit your Hosts file.
Edit The Hosts File On Ubuntu
In Ubuntu (and most Linux distributions) you tin edit nan hosts record straight successful nan Terminal. You tin usage your favorite command-line editor aliases your favourite GUI matter editor. For this illustration we will usage Vim, since it is 1 of nan accepted matter editors successful Linux. Ubuntu's hosts record location is nan /etc/ folder. The hosts record is protected, overmuch for illustration successful Windows, and your regular personification relationship will not beryllium capable to edit it.
You'll request to motorboat Vim prefaced by sudo, which is conceptually and functionally akin to "Run arsenic Administrator" connected Windows operating systems. Open up a Terminal, past enter:
sudo vim /etc/hostsYou'll request to participate your password earlier nan bid will execute.
If you get a connection notifying you that Vim is not installed, conscionable tally "sudo apt instal vim" successful a Terminal.
Now that it is unfastened we tin edit it to redirect Facebook into nothing. You will announcement that pinch Ubuntu location is besides a conception for IPv6.
You tin disregard nan IPv6 conception successful astir cases; conscionable editing nan IPv4 conception should do what you need.
Now we tin prevention nan record and effort to spell to Facebook.com. When you group nan reside successful nan hosts record to 0.0.0.0, your machine can't scope Facebook, and throws an error: "Unable to Connect."
If your browser has been configured to usage DNS Over HTTPS and its ain DNS Server, editing nan hosts record will astir apt not artifact access.
Change nan Hosts File connected Any macOS Version
In macOS, accessing nan hosts record is very akin to Ubuntu. Begin successful terminal and usage your favourite editor — it could moreover beryllium a GUI-based matter editor if you wish, but it is easier to usage a command-line editor from nan Terminal.
The hosts record connected macOS is located successful /etc/ conscionable for illustration connected Linux.
The record will look a batch for illustration nan hosts record recovered successful Windows and Linux. Again we are going to redirect Facebook to 0.0.0.0.
Safari, conscionable for illustration a browser connected Windows and Ubuntu, will beryllium incapable to link to Facebook.
Why Isn't The Hosts File Blocking Connections?
All of nan awesome modern browsers connection DNS Over HTTPS (DOH). DOH encrypts your DNS requests truthful that they can't beryllium intercepted and publication by 3rd parties that mightiness beryllium snooping --- successful general, this is simply a awesome thing.
For our purposes here, it limits nan inferior of nan hosts file. The hosts record tin only be utilized to artifact net postulation if your browser is deferring to nan DNS Server specified successful nan Windows operating system. A batch of browsers will alteration DNS Over HTTPS automatically and usage their ain DNS servers. That results successful nan browser wholly bypassing nan hosts file. It is imaginable to unit your browser to usage nan DNS Server Windows specifies, but you'll person to excavation done your browser's settings.
This should get you started successful knowing nan Hosts record and really it tin thief protect your computer. Under nan correct circumstances, you tin usage it to artifact sites that you don't want a PC to beryllium capable to access.