What is a hosts file in Windows 10?
A ‘hosts’ file is a plain text file, which maps hostnames to IP addresses. A host file helps in addressing network nodes in a computer network. A hostname is a human-friendly name or label assigned to a device (a host) on a network and is used to distinguish one device from another on a specific network or over the internet.
If you have been a tech-savvy person, you would be able to access and modify the Windows hosts file to solve certain issues or block any websites on your device. The hosts file is located at C:\Windows\system32\drivers\etc\hosts on your computer. Since it is a plain text file, it can be opened and edited in notepad. But Sometimes you may encounter ‘Access Denied’ error while opening hosts file. How will you edit the host file? This error will not let you open or edit the hosts file on your computer. In this article, we will discuss various methods to solve Can’t edit the hosts file on Windows 10 issue.
Editing a hosts file is possible and you might need to do it for a variety of reasons.
- You can create website shortcuts by adding a required entry in the hosts file that maps the website IP address to a hostname of your own choice.
- You can block any website or ads by mapping their hostname to the IP address of your own computer which is 127.0.0.1, also called loopback IP address.
Table of Contents
Make sure to create a restore point just in case something goes wrong.
Why can’t I edit the hosts file, even as Administrator?
Even if you try to open the file as an Administrator or use the built-in Administrator account to modify or edit the hosts file, you are still unable to make any changes to the file itself. The reason being that the access or permission required to make any changes to the hosts file are controlled by TrustedInstaller or SYSTEM.
Method 1 – Open Notepad with Administrator Access
Most of the people use notepad as a text editor on Windows 10. Therefore, before you edit the host file, you need to run Notepad as Administrator on your device.
1. Press Windows Key + S to bring up the Windows Search box.
2. Type notepad and in the search results, you will see a shortcut for Notepad.
3. Right-click on Notepad and select ‘Run as administrator’ from the context menu.
4. A prompt will appear. Select Yes to continue.
5. Notepad window will appear. Select File option from the Menu and then click on ‘Open‘.
6. To open the hosts file, browse to C:\Windows\system32\drivers\etc.
7. If you can’t see the hosts file in this folder, select ‘All Files’ in the option below.
8. Select the hosts file and then click on Open.
9. You can now see the contents of the hosts file.
10. Modify or make the required changes in the hosts file.
11. From Notepad menu go to File > Save or press Ctrl+S to save the changes.
It is important to note that this method works with all text editor programs. Therefore, if you use another text editor program apart from notepad, you just need to open your program with Administrator access.
Alternative Method:
Alternatively, you can open the notepad with admin access and edit the files using the Command Prompt.
1.Open the command prompt with admin access. Type CMD in Windows search bar then right-click on Command Prompt and choose Run as administrator.
2.Once the elevated command prompt opens, you need to execute the below-given command
cd C:\Windows\System32\drivers\etc notepad hosts
3.The command will open the editable host file. Now you can make the changes to the hosts file on Windows 10.
Method 2 – Disable Read-only for the hosts file
By default, the hosts file is set to open but you cannot make any changes i.e. it is set to read-only. In order to fix Access denied when editing hosts file error in Windows 10, you need to disable the read-only feature.
1.Navigate to C:\Windows\System32\drivers\etc.
2.Here you need to locate the hosts file, right-click on it and choose Properties.
3.In the attribute section, uncheck the Read-only box.
4.Click Apply followed by OK to save the settings
Now you can try to open and edit the hosts file. Probably, the problem of access denied will be solved.
Method 3 – Change the Security settings for the hosts file
Sometimes getting access to these files requires special privileges. It could be one reason that you may not be given full access, therefore, you are getting access denied error while opening hosts file.
1.Navigate to C:\Windows\System32\drivers\etc.
2.Here you need to locate the hosts file, right-click on the file and choose Properties.
3.Click on the Security tab and click on the Edit button.
4.Here you will find a list of users and groups. You need to ensure that your user name has full access and control. If your name is not added in the list, you can click on the Add button.
5.Select the user account via the Advanced button or just type your user account in the area which says ‘Enter the object name to select’ and click OK.
6.If in the previous step you have clicked on the Advanced button then click on “Find now” button.
7.Finally, click OK and checkmark “Full Control”.
8.Click Apply followed by OK to save changes.
Hopefully, now you will be able to access and edit the hosts file without any issues.
Method 4 – Change the hosts file location
Some users noted that changing the file location has solved their problem. You can change the location and edit the file thereafter put the file back to its original location.
1.Navigate to C:\Windows\System32\drivers\etc.
2.Locate the Hosts file and copy it.
3.Paste the copied file on your Desktop where you can easily access that file.
4.Open the hosts file on your Desktop with Notepad or another text editor with Admin access.
5.Make the necessary changes on that file and save changes.
6.Finally, copy & paste the hosts file back to its original location:
C:\Windows\System32\drivers\etc.
Recommended:
- Create Multiple Gmail Accounts Without Phone Number Verification
- Identify and Install Missing Audio & Video Codecs in Windows
- Fix The Diagnostics Policy Service Is Not Running Error
- 10 Ways To Fix Slow Page Loading In Google Chrome
That’s if you have successfully Fix Access denied when editing hosts file in Windows 10 but if you still have any queries regarding this article then please feel free to ask them in the comment’s section.
In most cases, the reason for “Access Denied” message while trying to edit the Hosts File on a Windows computer is due to the User not being logged-in to the Admin Account.
The Hosts File on a Windows computer is protected by Admin Password, which protects it from being used by malware programs to redirect users to unsafe websites or block access to certain websites.
It is possible to Edit the Hosts File on a Windows 11/10 computer from a non-admin account, without getting “Access Denied” message by using any of the following methods.
1. Run Notepad as Admin
In most cases, you should be able to Edit Hosts File by using Notepad with Admin Privileges.
Advertisement
1. Click on the Start button > type Note in the Search box > right-click on Notepad and select Run as Administrator option.
2. On the next screen, type your Admin Password and press the Enter key.
3. Once Notepad opens, select the File tab and click on Open.
4. In Open File dialogue box, navigate to C:\Windows\system32\drivers\etc and switch to All Files view.
Note: You won’t be able to view Hosts File without switching to All Files view.
5. Select the Hosts File and click on the Open button to open Hosts File in Notepad.
6. Make changes as required to the hosts file and Save the file.
2. Edit Hosts File on Desktop
Another way is to move the Hosts File to Desktop, make changes and move the Edited File back to its original location.
Advertisement
1. Using File Explorer, navigate to C:\Windows\System32\drivers\etc\ .
2. Select the Hosts File and drag it to the Desktop.
3. Click on Continue on “File Access Denied” pop-up,
4. On the next screen, enter your Admin Password and press the Enter key.
5. Open Hosts File on your desktop using Notepad and make changes as required.
4. After making changes, drag Hosts File back to C:\Windows\System32\drivers\etc\
5. Click on Continue on “Destination Folder Access Denied” pop-up,
6. On the next screen, enter your Admin Password to move the File back to its original destination.
3. Uncheck Read Only Box
It is possible that Hosts File has been saved in Read Only mode.
1. Using File Explorer, navigate to C:\Windows\System32\drivers\etc\.
2. Right-click on the Hosts File and click on Properties.
3. On Host Properties screen, uncheck Read-only Box in Attributes section.
4. Click on Apply & OK to save the changes.
If you are still unable to Edit Hosts files, you need to scan your computer for malware and see if this helps.
If you are unable to Edit Hosts File in Windows 10 and seeing “Access Denied” message, the problem is usually due to lack of User Permissions.
Encountering an error while attempting to edit the LMHOSTS or HOSTS file in Microsoft Windows 11 is a common issue. You may come across one of the following messages:
- “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.”
These errors usually indicate a lack of proper permissions to access the file. Fortunately, resolving this problem is relatively straightforward. Follow these steps to overcome the issue:
Allow Access One Time
- Select “Start” > “All Programs” > “Accessories“.
- Right-click on “Notepad” and select “Run as administrator“.
- If you are prompted for an administrator password or for a confirmation, type the password, or select “Allow“.
- Open the Hosts file or the Lmhosts file, make the necessary changes, and then click “Save” on the “File” menu.
Permanently Allow Access
Note: This option is not recommended as it may allow a virus or malware to easily modify the Hosts or Lmhosts file.
- Right-click the Hosts or Lmhosts file and select “Properties“.
- Select “Security“.
- Select the “Edit…” button to edit permissions.
- Select “Add…“.
- Type your username to allow just your account access, or type “EVERYONE” to allow access to anybody. Select “OK” when you’re ready.
- With the account you just added highlighted in the “Group or user names” area, select the “Allow” check for “Full control“. Select “OK” when you’re ready.
Congratulations! You now have access to edit the file, and you won’t receive any more “Access Denied” messages when attempting to work with it.
If you still encounter issues editing these files, it’s advisable to investigate whether malware or viruses are affecting your computer. You can try running a MalwareBytes scan to identify and resolve any potential threats.
Author Mitch Bartlett
Through my career that spans over 20 years I have become an expert in Microsoft Systems Administration, Android, and macOS. I started this site as a technical guide for myself and it has grown into what I hope is a useful knowledgebase for everyone.
- Главная
- Форум
- Личные форумы.
- Полезности от Adler
|
Т.е. с админскими правами все нормально. Программа запускаемая с правами администратора по идее должна его переписывать.
Последний раз редактировалось: Adler (2023-01-09 10:59), всего редактировалось 4 раз(а) |
Отправлено: 03-Май-2017 12:07
(спустя 15 минут)
Отправлено: 03-Май-2017 12:07
(спустя 15 минут)
Joker-2013 |
Как будто «права админа» друг другу рознь Вот тут, прав… Ограничения все равно присутствуют… |
Отправлено: 03-Май-2017 13:18
(спустя 1 час 10 минут)
Отправлено: 03-Май-2017 13:18
(спустя 1 час 10 минут)
Adler |
|
Отправлено: 03-Май-2017 13:26
(спустя 8 минут)
Отправлено: 03-Май-2017 13:26
(спустя 8 минут)
Ander_73 |
|
Отправлено: 03-Май-2017 13:49
(спустя 22 минуты)
Отправлено: 03-Май-2017 13:49
(спустя 22 минуты)
Adler |
|
Отправлено: 03-Май-2017 13:56
(спустя 7 минут)
Отправлено: 03-Май-2017 13:56
(спустя 7 минут)
nikzzzz |
41006
Как будто «права админа» друг другу рознь… А если в Manifest вместо asInvoker поставить highestAvailable или requireAdministrator ? |
Отправлено: 03-Май-2017 14:24
(спустя 27 минут)
Отправлено: 03-Май-2017 14:24
(спустя 27 минут)
nikzzzz |
|
Отправлено: 03-Май-2017 14:34
(спустя 9 минут)
Отправлено: 03-Май-2017 14:34
(спустя 9 минут)
Adler |
Есть другой аспект, если текстовый редактор (AkelPad, к примеру) запустить с правами администратора (через контекстное меню) — файл редактируется. А если, к примеру, в AkelPad открыть его с обычными правами, и при попытке сохранения, когда запросит права админа (функция AkelPad) — вылетает ошибка: то точно бы решил, что что то в софтине не так, а так возникают сомнения. Последний раз редактировалось: Adler (2017-05-03 14:35), всего редактировалось 2 раз(а) |
Отправлено: 03-Май-2017 14:34
(спустя 43 секунды)
Отправлено: 03-Май-2017 14:34
(спустя 43 секунды)
nikzzzz |
|
Отправлено: 03-Май-2017 14:54
(спустя 19 минут)
Отправлено: 03-Май-2017 14:54
(спустя 19 минут)
nikzzzz |
41019
Программка у всех в ошибку при попытке сохранении валится? У меня не валится, правда кодировку портит, вместо русских букв крякозябры. У файла кодировка ansi. |
Отправлено: 03-Май-2017 15:03
(спустя 9 минут)
Отправлено: 03-Май-2017 15:03
(спустя 9 минут)
Adler |
41022
У файла кодировка ansi. Буду иметь ввиду, если разберусь как победить права доступа. Думал наваяь её за 5 минут и забыть, но что то пошло не так … |
Отправлено: 03-Май-2017 15:30
(спустя 26 минут)
Отправлено: 03-Май-2017 15:30
(спустя 26 минут)
zdoba |
|
Отправлено: 03-Май-2017 15:38
(спустя 7 минут)
Отправлено: 03-Май-2017 15:38
(спустя 7 минут)
Adler |
41025
(запрашивает только разрешение на перезапись) Как то так:
Ну мне «монстр» не нужен как раз. Хотел сделать что то максимально простое. Изначально вообще хотел, что бы при запуске просто открывался блокнот с админскими правами и открытым файлом hosts. |
Отправлено: 03-Май-2017 15:50
(спустя 12 минут)
Отправлено: 03-Май-2017 15:50
(спустя 12 минут)
Ander_73 |
|
Отправлено: 03-Май-2017 16:01
(спустя 11 минут)
Отправлено: 03-Май-2017 16:01
(спустя 11 минут)
KaSpieC 666 |
|
Страница 1 из 4
Текущее время: 06-Май 21:40
Часовой пояс: UTC + 3
Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете голосовать в опросах
Вы не можете прикреплять файлы к сообщениям
Вы можете скачивать файлы
-44 / 0 / 0 Регистрация: 29.11.2016 Сообщений: 36 |
|
24.01.2017, 19:31. Показов 7786. Ответов 7 Всем привет, ситуация уже доходит до абсурдности. Как админ не могу ни перезаписать файл hosts, ни отредактировать (предварительно создав на рабочем столе и перетянуть). Недавно ставил Open Server он запуститься не может. пишет мол беда с файлом hosts, не могу ничего в него записать. Почему ситуация абсурдная? Сейчас поставил для теста 10ку до этого стояла 7ка, там ситуация была точно такая же=) Ну давно уже нужно было ставить другую систему, думаю для 10 время пришло, та же проблема с этим файлом. Может это новая фишка винды, против подмены адресов не дает писать в него, это все хорошо, но как легально админу разрешить в него писать что нужно и тем прогам которым нужно. Кто в теме, как решить ситуацию=) Добавлено через 10 минут
0 |
22195 / 12116 / 653 Регистрация: 11.04.2010 Сообщений: 53,466 |
|
24.01.2017, 19:32 |
|
я в семерке, без проблем редактирую хост… вирье кстати тоже…
0 |
-44 / 0 / 0 Регистрация: 29.11.2016 Сообщений: 36 |
|
24.01.2017, 19:50 [ТС] |
|
Дык понимаешь, я вообще в кататоническом ступоре, такой проблемы никогда не было ни на 7ке ни на 10 (когда раньше ставил), тем более не первый год с компом, а здесь оп и ситуация. Учетка админская, другой винда не выдает при инсталляции. Раньше все тоже ставилось и редактировалось на раз два.
0 |
22195 / 12116 / 653 Регистрация: 11.04.2010 Сообщений: 53,466 |
|
24.01.2017, 20:21 |
|
чем открываете? не total commander- ом?
0 |
-44 / 0 / 0 Регистрация: 29.11.2016 Сообщений: 36 |
|
24.01.2017, 20:48 [ТС] |
|
ничем не открываю, просто создал файл hosts на рабочем столе, сверху кидаю драгэндпропом про права рассказывает сказки, уже поставил на папку владельца мой акк, уже дал права этому админскому акку на все и наследования и все права на папку etc на файл, по барабану, при копировании, нет прав. Какой то походу процесс системный держит файл.
0 |
22195 / 12116 / 653 Регистрация: 11.04.2010 Сообщений: 53,466 |
|
24.01.2017, 20:51 |
|
ыыы
0 |
6520 / 4096 / 1606 Регистрация: 09.05.2015 Сообщений: 9,560 |
|
24.01.2017, 20:54 |
|
А вы уверены что у вас админ права? По умолчанию даже у админа не админ права, пока вы запрос UAC не подтвердите. А так у меня на десятке все норм редактируется.
0 |
-44 / 0 / 0 Регистрация: 29.11.2016 Сообщений: 36 |
|
24.01.2017, 20:56 [ТС] |
|
да вообще с ним не дает работать на запись, скопировать из папки etc в любое место без проблем, а перезаписать hosts в папке etc отказывается категорично)) или Open Server или Denwer проге (это веб сервера локальные) не дает на запись, а эти проги не стартуют без доступа на запись к этому файлу. >>А вы уверены что у вас админ права? По умолчанию даже у админа не админ права, пока вы запрос UAC не подтвердите. А так у меня на десятке все норм редактируется. Всегда были права, редактировал раньше hosts, а теперь права убежали?=)
0 |