Некоторые пользователи, решившие проверить или отредактировать файл hosts в Windows могут обнаружить, что его нет в папке C:\Windows\System32\drivers\etc а иногда о том, что файл hosts не существует может сообщить и какой-то антивирус или утилита для удаления вредоносных программ.
В этой инструкции подробно о том, что можно сделать в ситуации, когда файла hosts нет в стандартной папке, как это исправить и обязательно ли это делать.
Расположение файла hosts и возможность его изменения
Прежде чем приступить, рекомендую зайти в Папку C:\Windows\System32\drivers\etc, открыть параметры проводника (сделать это можно в меню Проводника) и включить показ как скрытых, так и защищенных системных файлов — это две отдельные отметки, показаны на скриншоте ниже.
Если после включения отображения скрытых и системных файлов файл hosts всё так же не наблюдается в указанной папке, имеет смысл проверить, а не было ли изменено его стандартное расположение.
Папка, в которой находится файл hosts прописывается в реестре и может быть изменена. Чтобы проверить, не в этом ли причина отсутствия этого файла, выполните следующие шаги:
- Нажмите правой кнопкой мыши по кнопке «Пуск», выберите пункт «Выполнить», введите regedit и нажмите Enter.
- В открывшемся редакторе реестра перейдите к разделу
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
- В правой панели редактора реестра обратите внимание на значение параметра DataBasePath, по умолчанию там должно быть прописано
%SystemRoot%\System32\drivers\etc
- Если значение отличается, вы можете заглянуть в указанную по факту папку и посмотреть, имеется ли файл hosts там. Если в пути используются ссылки на папки вида %SystemRoot% и вы не знаете, что это за путь, можно дважды нажать по параметру DataBasePath, скопировать этот путь, а затем вставить в адресную строку проводника.
- При желании вы можете изменить значение параметра, равно как и место хранения файла hosts на стандартное: дважды нажмите по параметру DataBasePath, введите значение %SystemRoot%\System32\drivers\etc и сохраните настройки.
- Если значение параметра не было изменено, значит hosts должен располагаться в стандартной папке, но по какой-то причине был удален или не был создан, об этом поговорим далее.
Обратите внимание, если путь к месту расположения файла hosts был изменен, при этом вы лично его не меняли, а речь идет о «чистой» (не какой-либо «сборке») Windows, возможно, это расположение было изменено какими-то сторонними программами, не всегда полезными. Может иметь смысл проверить компьютер специальными средствами удаления вредоносных программ и инструментами, такими как Dr.Web CureIt!
Восстановление файла hosts
Если пути к месту хранения файла hosts не менялись, но его в нужном расположении нет, то следует учитывать два момента:
- В общем случае отсутствие файла hosts никак не влияет на работу вашей Windows 11/10 — по умолчанию этот файл пустой и содержит лишь комментарии, которые не используются в работе. То есть функционально нет разницы (при условии, что вы не планируете вносить собственные записи в файл): будете ли вы восстанавливать стандартный файл hosts или решите этого не делать.
- Вы легко можете восстановить этот файл: файл hosts это простой текстовый файл в кодировке UTF-8 и без расширения.
Чтобы восстановить файл, вы можете (привожу упрощенный вариант для начинающих пользователей):
- Открыть «Блокнот» (например, используя поиск в панели задач) или другой простой текстовый редактор.
- При желании вставить следующий стандартный код файла hosts (он не функционален, поэтому совершенно не обязателен).
# 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 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost
- В меню Блокнота выбрать «Файл» — «Сохранить» и сохранить его с именем hosts и без расширения, лучше всего — на рабочий стол (сохранить сразу в нужную папку, не запустив блокнот от имени Администратора не получится). Для сохранения без расширения в поле «Тип файла» выберите «Все файлы», введите имя файла hosts (без .txt), кодировка – UTF-8.
- Перенести файл с рабочего стола в папку C:\Windows\System32\drivers\etc — для этого вы должны иметь права администратора на компьютере, при переносе появится соответствующий запрос.
На этом всё: файл будет в нужном расположении и исправно работать, при условии, что в реестре для его расположения указана стандартная папка. Подробнее про редактирование файла hosts в Windows 11 и изменение файла hosts в предыдущих версиях Windows.
Hosts files are text files that help your system in the process of mapping hostnames to IP addresses. Apart from helping in mapping, you can also use Hosts Files to block certain websites or even redirect traffic. These are a crucial part of your operating system, as they allow your system to establish a secure connection with all the websites on the internet. These files failing to work can make you face serious internet-related issues. Therefore, in this guide, let us look at how we can fix the Hosts File not working in Windows 11.
Fix Hosts File Not Working in Windows 11
Here’s a compiled list of troubleshooting methods that may help you fix the Hosts file not working on your Windows 11 computer.
1. Check the Syntax in the Hosts File
The first thing you should do when the Hosts file is not working on your Windows 11 PC checks the syntax inside the file. The correct syntax that you should use in a Hosts file is first you type the name of the IP address, followed by a space or tab, and then you write the domain name.
However, note that you should give a single block space or only one tab space between the IP address and domain name, and for the gap between both, use only one option, either space or tab.
2. Check for the Comments Marker in the Hosts File
In new Hosts Files, there’s a comment marker or the ‘#‘ symbol at the start of every line. When your system sees a comment marker in the Hosts File, it knows that the following line is unimportant, and the system should ignore it.
Now, after you make changes in a new Hosts file, suppose you forget to remove the comment marker. It can be an unintentional mistake on your side, but your computer will now see that edited line with the comment marker as unimportant, causing the Hosts File to fail to work. Therefore, use correct formatting and comment markers in the right place to make a Hosts File work in Windows 11.
3. Check the Location of the Hosts File
If the syntax is correct, and there are no comments markers in the file, but you’re still getting the error, it can be due to the file’s location. For a Hosts file to work, it needs to be stored in the right folder, so if you’ve moved the file to another location, we recommend you put the file in the right folder. Here’s how to do it:
1. Open the folder where the current Hosts file is located.
2. Right-click on the file and use the cut option.
3. Head to the following location:
C:\Windows\System32\drivers\etc
4. Paste the file.
4. Check if You’re Using the Correct Encoder
Another minimal human error that can cause the Hosts File to not work on your system is the incorrect configuration of the encoder. The Hosts File uses a very specific encoding format (usually the ANSI format), and if you’ve saved it with some other encoding format like UTF-8 or Unicode, your system can face difficulty accessing the content of the Hosts File, causing it to not work on your computer.
Therefore, while editing Hosts Files in Windows 11, you should always use the correct encoder. Follow these steps to know how you can set the right encoder for Hosts Files in Windows 11:
1. Open the File Manager app, paste the following address, and press the enter key.
C:\Windows\System32\drivers\etc
2. Double-click on the Hosts file, choose to open with the Notepad app, and once the file is open, press Ctrl + Shift + S.
3. You can see the encoding option next to the Save button. Open the encoding’s drop-down menu, select ANSI, and hit the Save button.
5. Check if You’ve Set the Correct Windows Registry Path
Windows Registry is the pro max version of the Settings app in Windows 11. The registry contains all the settings and configurations that you’ll ever need and provides you with more control over your PC. Sometimes, you make changes to a Hosts File and forget to update its registry path. This forgetting will cause conflict when your system tries to access or use the Hosts File. Therefore, you should always correct/update the registry path after editing a Hosts File. Here’s how you can do it in Windows 11:
1. Open the Start menu’s search bar, type Registry Editor, and press the enter key.
2. Click on the Parameters folder, which you can find by opening the following folders.
(HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services > Tcpip)
3. Click on DatabasePath, and under the Value data section, paste the location path of the Hosts file.
6. Check if the Hosts File Has Required Permission
As the Hosts File is a vital system component, making changes to it is not advisable. However, if it’s required to do so, then only you should edit it. Also, after updating the Hosts File, make sure that you give the file all the required permissions. Moreover, also ensure that the Hosts File is not read-only, as it can cause conflicts when your system is trying to use the file.
7. Restart DNS Client Service
If the DNS Client Service is not working correctly, it can cause issues with the Hosts file on your Windows computer, as it’s responsible for resolving domain names to IP addresses. The easiest way to fix this is by restarting the DNS client. Here’s how you can do it:
1. Press Win + R to open Run Dialog Box, type services.msc, and press the enter key.
2. Scroll down, find DNS Client, right-click, and choose the Restart button.
8. Flush DNS Cache
Another effective method to fix the Hosts File not working on Windows 11 is flushing the DNS Cache. The DNS Cache contains a list of websites and their IP addresses that you’ve accessed on your computer. We know that the Hosts File is responsible for the connection between a website and your computer, and it is also true that DNS Cache also plays an important role in the connection procedures.
Now, if there’s an issue with the DNS cache on your system, like the data being corrupted or outdated, your Hosts File may fail to work. Therefore, to avoid such issues, try flushing the DNS cache on your computer. Here’s how you can do it:
1. Open the Command Prompt, type the following command, and press the Enter key on your keyboard.
ipconfig /flushdns
9. Reset TCP/IP Settings
If your Hosts file is not working because it is using wrong settings or incorrect data, then resetting the TCP/IP settings may solve your problem, as the TCP/IP protocol is the one that allows your system to establish a connection to other computers on the network. Resetting it will change all the connection-related settings to default, fixing the error with the Hosts File. Here’s how you can do it:
1. Open the Start menu search, type Command Prompt, and click on Run as administrator.
2. Execute the following command.
netsh int ip reset
3. After executing, restart the computer.
10. Reset NetBIOS Cache
On a local network, a computer uses the NetBIOS protocol for mapping devices and IP addresses. If the data in the NetBIOS cache doesn’t get updated with time, it can cause issues with the Hosts File on your computer. For fixing this issue, the only option is resetting the NetBIOS cache. Here’s how you can reset the NetBIOS cache in Windows 11:
1. Launch the Command Prompt app with administrator privileges.
2. Type the following command and press the Enter key.
nbtstat -R
3. Restart your computer.
11. Reset the Hosts File to Default
If you’ve edited the Hosts File incorrectly and it is now full of errors ranging from formatting ones in the file to having the wrong encoder, then resetting might be the best option for you. Resetting will remove all the changes that you’ve made to the Hosts File and replace it with the system default files. Therefore, it’s recommended to take a backup of all your custom entries before moving forward in this process. Once you’ve done that, follow these steps to reset a Hosts File in Windows 11:
1. Delete the current Hosts file from the following location and reboot the computer. Upon rebooting, the operating system will create a new default Hosts file.
C:\Windows\System32\drivers\etc
2. Type the following in the address bar of the File Explorer app and hit the Enter button.
3. Lastly, you can delete the custom entries and paste the following in the Hosts file, and hit the save button.
# 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 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:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
12. Temporary Disable Third-Party Antivirus Software
Third-party antivirus software has a history of interfering with system processes and the working of other applications, so if the above fixes are not working for you, try disabling the antivirus software on your computer.
Typically, you can disable the third-party antivirus software by first right-clicking on the antivirus icon in the system tray or notification area and then clicking the turn-off or disable option.
Now that the antivirus protection is off check if you can access the websites or network resources. If doing this has fixed your problem, then you need to configure your antivirus software and remove Hosts Files from its network filtering list.
13. Disable Proxy
A misconfigured proxy setting can also be the reason why the Hosts File is not working on your system. Now, to tackle this issue, there are two things that you can do: use the correct proxy settings or turn off the proxy. You can find the correct proxy settings for almost all the servers on the internet, and if you want to turn off the proxy server on your computer, follow these steps:
1. Open the Settings app on your PC.
2. Click on Network & internet.
3. Click on Proxy to open its settings.
4. Under Manual proxy setup, make sure the switch is set to Off.
14. Create a New Hosts File
If the data inside the Hosts file on your computer is invalid or corrupted, or for any reason, you’re unable to edit or change the entries in the Hosts file, creating a new file may solve the issue for you.
In the new Hosts file, you can add necessary entries like domain names and IP addresses for websites and network resources that you will access. Here’s how you can create a new Hosts file on Windows 11:
1. Open the Command Prompt application on your system.
2. Type the following command and press the Enter button.
echo > %WinDir%\System32\drivers\etc\hosts
After executing the command, a new and empty Hosts file will be created in the default location. Now add the necessary entries in the new Hosts file, and check if you’re able to access websites or network resources that were not working earlier.
15. Flush Socket Pool in Chrome Browser
If you’re facing the connectivity issues only in the Chrome browser, then there’s a chance that it might be fixed by flushing the Socket pools as once you flush the socket pool, any cached DNS entry that may be interfering with the Hosts file will be cleared. Here’s how you can flush socket pools in Chrome web browser:
1. Open the Chrome browser.
2. Type the following into the address bar and press the Enter key.
chrome://net-internals/#sockets
3. Click the Flush socket pools button.
4. Restart the Chrome browser.
16. Use a Different User Account
If there are multiple user accounts on your system, try logging into another one to check if the error is account-specific or not. Here’s how you can switch user accounts in Windows 11:
1. Press the Windows key + I to open the Settings app.
2. Click on Accounts.
3. Click on Other users.
4. Click Add account.
5. Follow the prompts to create a new local account.
6. Log out of your current user account.
7. Log in to the new user account you just created.
17. Run System File Checker
If none of the above methods worked for you, there are chances that the problem is with corrupted or invalid files, therefore running an SFC/ system file checker scan can be a useful troubleshooting step. Follow these steps to run a system file checker scan:
1. Launch the Command Prompt with administrator privileges on your computer.
2. Type the following and press the Enter button on the keyboard to start the scan.
sfc /scannow
The scan may take some time to finish, but once it does, restart your computer.
18. Perform a System Restore
If you’re facing this error after any Windows 11, then performing a System Restore can help. For those who don’t know, Windows 11 comes with a System Restore feature using which you can restore your software version to any point in the past, as long as you have a restore point created for that time. Follow these steps to perform a System Restore in Windows 11:
1. Launch the Settings app on your PC.
2. Scroll down and click on Recovery.
3. Click the Restart Now button next to the Advanced Startup settings.
4. When the Choose an option screen appears, select Troubleshoot, followed by Advanced options, and System Restore.
5. Follow the prompts to select a restore point and restore your computer to a previous state.
6. Once the restore is complete, your computer will restart.
Final Words
You have reached the end of this guide on How to Fix Hosts File not working in Windows 11. We hope that one of the mentioned fixes has worked for you. If you’re still facing the issue, try reinstalling the Windows OS, as it is the ultimate method for solving any software-related bug.
The Hosts file in Windows 11/10, is used to map hostnames to IP addresses. This Hosts file is located deep down in the Windows folder. It is a plain text file, and the size of the original default Hosts file is around 824 bytes.
The HOSTS file is 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. Moreover, the IP address and the host name should be separated by at least one space.
In this post, we will see its location and also how to manage, lock, or edit the Hosts file in Windows 11/10. We will discuss the following:
- Host file location
- Lock Hosts file to prevent hijacking
- Block website using the Hosts file
- How to edit the Hosts file
- Using free Hosts File Editor software.
Let us take a look at them.
Host file location in Windows
The Hosts file in Windows is located at the following location:
C:\Windows\System32\drivers\etc
Lock Hosts file to prevent hijacking
Imagine clicking on www.thewindowsclub.com and seeing a completely different website load in your browser. Malware can redirect Web addresses on your computer by altering your Hosts file. This is referred to as the Host File Hijack.
To prevent Host file hijacks, you may navigate to it, right-click on it, select Properties and make it a Read-only file. This will lock down your Hosts file and prevent anyone or any malware from writing to it.
Block website using the Hosts file
To block a website using the Hosts File, simply add the following entry:
127.0.0.1 blocksite.com
Although I do not do it, many users like to manually add entries to it in order to block the opening of one or more particular websites. Others, like to download and use List from well-known sources like mvps.org, to add entries that block malware sites from opening.
How to edit Hosts file in Windows 11/10
To edit the Hosts file in Windows 11/10:
- Open Explorer
- Navigate to \System32\drivers\etc\ location
- Locate Hosts file
- Right-click on it and select Notepad
- Make the changes and Save.
Now let us go into a detailed explanation.
To edit the Hosts file, navigate to the following folder location:
C:\Windows\System32\drivers\etc\
Here you will see the Hosts file. Right-click on it and select Notepad. Make the changes and Save.
But sometimes, even when you are logged on with administrative credentials, you may receive the following error message:
Access to C:\Windows\System32\drivers\etc\ hosts was denied
Or
Cannot create the C:\Windows\System32\drivers\etc\hosts file. Make sure that the path and file name are correct.
In this case, type Notepad in Start search and right-click on the Notepad result. Select Run as administrator.
Open the Hosts file, make the necessary changes, and then click Save.
Using free Hosts File Editor software
If you are looking for an easier way, you can use a free Hosts file Editor software.
1] Using HostsMan
While you can always manually manage or edit Hosts file manually, I would like to suggest that you use a third-party freeware tool like HostsMan to do it.
HostsMan is a feature-rich tool that lets you add, remove, edit entries in the Hosts file. It also lets you easily add third-party Hosts lists that help in blocking malware sites and lets you easily enable or disable the Hosts file. It includes a built-in hosts file updater & a hosts editor. It lets you scan the hosts file for errors, duplicates, and possible hijacks – and also lets you create an Exclusion list. One more useful feature it offers is the Hosts file backup manager. Backup your Hosts file to a safe place and use it to restore it, should the need arise.
Hostman also lets you Flush DNS cache, open Hosts with a text editor, count the number of hosts, find duplicates, replace IP, scan hosts for malicious entries, rearrange hosts, manage DNS Client Service, and more. In short, it’s the only Hosts Manager that you will ever need. You can download it from its home page.
TIP: SwitchHosts is a Hosts file switcher for Windows that allows you to change your Hosts file with a click. It is useful if you need to have two Hosts files on your PC.
2] Using SysMate Hosts File Manager
SysMate Hosts File Manager and is another tool that lets you do so. With Host File Walker you can add as many records to the system hosts file. It even lets you backup and restore the Hosts File.
3] Using Host File Editor tool
Host File Editor is another good tool that you can use. It has the following features:
- Enable and disable hosts file from the system tray
- Cut, copy, paste, duplicate, enable, disable and move entries
- Filter and sort host entries
- Backup and restore various hosts file configurations when switching between environments
- Ping endpoints to check availability.
You can download it from here. It offers a portable version too.
4] HostsDock
HostsDock is another useful software to edit the hosts file on Windows 11/10 computers. This is an open-source hosts file editor software that also lets you create new local hosts files and save them. You can also connect to a remote hosts file which is an important option. Some other interesting features are also available which are as follows:
- Syntax Highlighter that can automatically highlight IP addresses, comments, domains, etc., present in the hosts file. It detects all these items by itself and then highlights them
- Basic editing options like undo/redo, search and replace, cut, paste, etc.
- Create folding block
- Test IP addresses in the hosts file with the ping command
- A navigation pane to quickly switch to local and remote hosts files, check system hosts info, etc.
You can download this tool from eshengsky.github.io. Launch the tool after installation and it will show the system hosts file. After that, you can use the available options to add or create a new hosts file, use editing options, export the hosts file, and more.
5] Hosts File Editor PowerToy
The Hosts File Editor PowerToy also lets you edit the Hosts file.
How do I grant permission to edit the Hosts file in Windows 11/10?
If you want to grant permission to edit the hosts file in Windows 11/10 using Notepad, then you need to run Notepad as an administrator. You should also sign in to your Windows 11/10 system with an administrator account to edit hosts file so that you won’t get any errors while saving the hosts file.
Read: What is LMHOSTS file in Windows?
Do not have permission to edit the Hosts file?
If you are unable to edit the hosts file on Windows 11/10 or you do not have permission to edit the hosts file, then you can use the following solutions:
- Use Notepad with administrative privileges and then open a hosts file to edit it
- Copy the hosts file from the original location to the desktop or some other location, edit that file, and then copy the edited file and paste it into the original location to overwrite the hosts file
- Use some third-party hosts file editing tools, etc.
TIP: See this post if Hosts File is not working in Windows. How to manually reset the Hosts file back to default in Windows may also interest you.
If your browser has been hijacked, you might find this post on Browser Hijacking and Free Browser Hijacker Removal Tools helpful.
There are numerous ways to find the IP address in Windows 11, but what if you want to find and edit the hosts file in Windows 11? The hosts file is a powerful method to restrict or allow a certain website on your PC. It allows you to add an IP address for a particular domain, and the browser will point to that specific address. So we have put together a nifty guide on how to find and edit the hosts file in Windows 11. Moreover, we have included an explainer of what the hosts file does in Windows 11, so you can grasp the concept in easy terms. On that note, let’s move to the steps you need to follow.
We have mentioned the location of the hosts file in Windows 11 in this guide, so you can edit it with ease. Moreover, we have also explained what is the hosts file and what is its use on your Windows 11 PC.
What is the Hosts File in Windows 11?
When you open a website on your PC, the browser looks for the IP address of the domain name from a DNS server. However, before that, it goes to the “hosts” file on your Windows PC first to find if the user has specified an IP address for a particular domain. If you have specified a website to a non-existent IP (such as 0.0.0.0), the website won’t open and will effectively be blocked. In essence, the hosts file keeps a list of all the websites that you have blocked on your PC.
Having said that, if you are using one of the popular DNS servers in your browser, the browser will ignore the hosts file. It will directly go to the DNS server or DNS cache to fetch the IP address of the website (domain name) you visit. To avoid this situation, we will suggest enabling DNS over HTTPS (DoH) on Windows 11 from the system settings. It will ensure that you get all the encrypted protection of DoH while also taking the hosts file into account. In this scenario, the websites mentioned in the hosts file will be blocked, and you will also get encrypted DNS communication.
So, to sum up, the hosts file in Windows 11 allows you to block websites by pointing them to a made-up IP address. It’s an easy and effective solution for users who want to restrict certain websites on their PC, from all browsers.
How to Find the Hosts File in Windows 11
1. First, press the Windows 11 keyboard shortcut “Windows + E” to open the File Explorer. Here, double-click to open the “C” drive.
2. Next, move to the “Windows” folder.
3. After that, navigate to system32 -> drivers -> etc folder. Here, you will find the “hosts” file that we need to edit. It will be a “File” type and not “Calendar”.
4. If you don’t see the “hosts” file in this folder, click on “View” in the top menu and click on “Show”. Now, choose “Hidden items“. This will show all the hidden items, including the “hosts” file.
Windows 11 Hosts File Location
You can navigate to the following address – “C:\Windows\system32\drivers\etc” to find the hosts file on Windows 10 and 11. While you need admin permissions to edit the hosts file at its original location, we will take a slightly different route here. So keep reading.
How to Edit the Hosts File in Windows 11
1. First, make a copy of the “hosts” file to a different location, like the Desktop. It will allow you to edit the Hosts file in Windows 11 with ease and without admin privileges.
2. Now, move to the copied hosts file, right-click on it and choose “Open With”. Here, select “Notepad“.
3. To block websites using the “hosts” file in Windows 11, add a line at the bottom by following the below syntax. Here, you are pointing twitter.com to 0.0.0.0, which is a non-existent IP address. The sentence after # is a comment, and it’s optional. You can add as many websites to the hosts file as you want using the below syntax.
0.0.0.0 twitter.com #Your PC will block twitter.com
4. Now, click on “File” in the top menu and choose “Save“.
5. After that, copy and move the modified “hosts” file to the “etc” folder to replace it. It will ask for administrator permission, and you need to click on “Continue“.
6. Finally, go ahead and open twitter.com, and it won’t open on your Windows 11 PC since the IP address for this website is mapped to a non-existent IP address. So that is how you can find and edit the hosts file in Windows 11 to block websites.
7. In case you want to unblock the website, simply remove the line you added in the hosts file or add # in the beginning of the line to turn the whole text into a comment. This will make the command ineffective. Now, move the modified hosts file to the “etc” folder again to have the changes take effect.
Frequently Asked Questions (FAQ)
What is the Hosts file in Windows 11?
The hosts file essentially contains a list of websites you want to block on your PC. You can also use the hosts file in Windows 11 to point a domain name to a particular IP address.
Where to find the Hosts file in Windows 11?
The hosts file in Windows 11 is located at C:\Windows\System32\drivers\etc .
What is the use of the Hosts file in Windows 11?
You can use the hosts file in Windows 11 to block websites on your PC by pointing them to a non-functional IP address.
Can we enable DNS over HTTPS with a Modified Hosts file?
Yes, you can use DNS over HTTPS and route traffic to the ghosts file at the same time. However, you need to enable DNS over HTTPS from Windows Settings and not through the browser.
Edit the Hosts File to Block Websites in Windows 11
So that is how you can locate and edit the hosts files in Windows 11. Reiterating again, if you want your PC to look for blocked hosts on your Windows PC, you will have to disable DNS over HTTPS from your browser. And if you have enabled DNS over HTTPS from the PC settings, you don’t need to do anything. Windows 11 will take the hosts file into account. Anyway, that is all from us. If you want to find the Windows 11 Startup folder in Windows 11, use our linked guide. And to find your MAC address in Windows 11, we have a handy guide for that as well. Finally, if you have any questions, let us know in the comment section below.
Applies ToWindows 8 Windows 8.1 Windows 7 Windows Vista Windows XP Windows 10 Windows 11
Аннотация
Рекомендации, приведенные в этой статье, позволяют вернуть содержимое файла hosts к используемому по умолчанию.
Что такое файл Hosts
Файл Hosts используется операционной системой для сопоставления удобных для человека имен узлов с числовыми IP-адресами, которые идентифицируют и находят узел в IP-сети. Файл hosts является одним из нескольких системных ресурсов, которые адресуют сетевые узлы в компьютерной сети и являются общей частью реализации IP-адресов операционной системы.
Файл Hosts содержит строки текста, состоящие из IP-адреса в первом текстовом поле, за которым следует одно или несколько имен узлов. Каждое поле отделено пробелом (по историческим причинам часто предпочтение отдают знакам табуляции, но пробелы также используются). Файл также может включать строки с примечаниями, обозначенные символом #, который ставится в начале каждой такой строки. Пустые строки в файле игнорируются.
Если файл Hosts изменен по умолчанию, сброс его может помочь устранить некоторые проблемы с подключением.
Решение
Чтобы восстановить параметры файла Hosts по умолчанию, выполните указанные ниже действия в зависимости от используемой версии операционной системы.
Чтобы восстановить параметры файла hosts по умолчанию, выполните указанные ниже действия.
1. Откройте Блокнот. Для этого найдите «Блокнот», а затем коснитесь или щелкните значок Блокнот .
2. Скопируйте следующий текст и вставьте его в файл:
-
# 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
3. В меню Файл выберите Сохранить как, введите hosts в поле Имя файла (как показано на следующем рисунке), а затем сохраните файл на рабочем столе.
4. Закройте Блокнот.
5. Выполните поиск по запросу %WinDir%\System32\Drivers\Etc, а затем щелкните значок папки «Файл «.
6. Коснитесь и удерживайте файл Hosts или щелкните его правой кнопкой мыши, выберите команду Переименовать, а затем переименуйте файл в Hosts.old.
7. Скопируйте или переместите файл Hosts, созданный на шаге 3, с рабочего стола в папку %WinDir%\System32\Drivers\Etc . Если вам будет предложено ввести пароль администратора, нажмите кнопку Продолжить.
Чтобы восстановить параметры файла hosts по умолчанию, выполните указанные ниже действия.
1. Откройте Блокнот. Для этого найдите «Блокнот» с помощью Кортаны, а затем коснитесь или щелкните значок Блокнот .
2. Скопируйте следующий текст и вставьте его в файл:
-
# 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
3. В меню Файл выберите Сохранить как, введите hosts в поле Имя файла (как показано на следующем рисунке), а затем сохраните файл на рабочем столе.
4. Закройте Блокнот.
5. Выполните поиск по запросу %WinDir%\System32\Drivers\Etc с помощью Кортаны, а затем щелкните значок папки «Файл «.
6. Коснитесь и удерживайте файл Hosts или щелкните его правой кнопкой мыши, выберите команду Переименовать, а затем переименуйте файл в Hosts.old.
7. Скопируйте или переместите файл Hosts, созданный на шаге 3, с рабочего стола в папку %WinDir%\System32\Drivers\Etc . Если вам будет предложено ввести пароль администратора, нажмите кнопку Продолжить.
Чтобы восстановить параметры файла hosts по умолчанию, выполните указанные ниже действия.
1. Откройте Блокнот. Для этого проведите пальцем от правого края экрана, коснитесь пункта Поиск, введите Блокнот, а затем коснитесь значка Блокнота . Если вы используете мышь, наведите указатель мыши на правый верхний угол экрана, переместите указатель мыши вниз, нажмите кнопку Поиск, введите Блокнот, а затем — Блокнот.
2. Скопируйте следующий текст и вставьте его в файл:
-
# 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
3. В меню Файл выберите Сохранить как, введите hosts в поле Имя файла (как показано на следующем рисунке), а затем сохраните файл на рабочем столе.
4. Закройте Блокнот.
5. Откройте папку %WinDir%\System32\Drivers\Etc. Для этого выполните следующие действия:
-
а. Проведите пальцем от правого края экрана, коснитесь пункта Поиск, введите выполнить, а затем коснитесь значка Выполнить . Или, если вы используете мышь, наведите указатель на правый верхний угол экрана, переместите указатель мыши вниз, выберите Поиск, введите выполнить, а затем щелкните значок Выполнить .
-
б. В поле Открыть введите команду %WinDir%\System32\Drivers\Etc и нажмите кнопку ОК.
6. Выберите файл Hosts, выберите Переименовать, а затем переименуйте файл в Hosts.old.
7. Скопируйте или переместите файл Hosts, созданный на шаге 3, в папку %WinDir%\System32\Drivers\Etc. Если вам будет предложено ввести пароль администратора, нажмите кнопку Продолжить.
Чтобы самостоятельно восстановить параметры файла hosts до значений по умолчанию, сделайте следующее:
-
Нажмите кнопку Пуск, нажмите кнопку Выполнить, введите Notepadи нажмите кнопку ОК.
-
Найдите свою версию Windows из приведенного ниже списка и скопируйте следующий текст для этой версии Windows, а затем вставьте его в Блокнот:
-
Для Windows 7:
- # 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
-
Для Windows Vista или Windows Server 2008:
- # 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host 127.0.0.1 localhost ::1 localhost
-
Для Windows XP или Windows Server 2003:
- # Copyright (c) 1993-1999 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: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host 127.0.0.1 localhost
3. В меню Файл выберите Сохранить как, введите hosts в поле Имя файла , а затем сохраните файл на рабочем столе.
4. Выберите Пуск > Выполнить, введите %WinDir%\System32\Drivers\Etc, а затем нажмите кнопку ОК.
5. Выберите файл Hosts и переименуйте его в Hosts.old.
6. Скопируйте или переместите файл Hosts, созданный на шаге 3, в папку %WinDir%\System32\Drivers\Etc. Если вам будет предложено ввести пароль администратора, нажмите кнопку Продолжить.
Дополнительная информация
Поддержка Windows XP прекращена
Корпорация Майкрософт прекратила поддержку Windows XP 8 апреля 2014 г. Это могло повлиять на безопасность и своевременную установку обновлений для вашего программного обеспечения. Узнайте, что это значит для вас и как оставаться защищенным.
Поддержка Windows Server 2003 прекращена 14 июля 2015 г.
Корпорация Майкрософт прекратила поддержку Windows Server 2003 14 июля 2015 г. Это могло повлиять на безопасность и своевременную установку обновлений для вашего программного обеспечения. Узнайте, что это значит для вас и как оставаться защищенным.
Нужна дополнительная помощь?
Нужны дополнительные параметры?
Изучите преимущества подписки, просмотрите учебные курсы, узнайте, как защитить свое устройство и т. д.
