Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't edit the host file

I've been trying to edit my host file for a while now and I keep failing. I tried to open notepad as administrator and then click File --> Open and choosing the host file but I get this error message:

hosts

You don't have permission to open this file.

Contact the file owner or an administrator to obtain permission.

I tried notepad++ as well (as administrator) but I couldn't even get to the file with it (it doesn't show the etc folder in drivers). I also tried to check my "User Account Control Settings" but it was already on the lowest level (never notify). While looking online for a solution I've noticed more people having the same problem but I couldn't find a solution that worked for me.

I'm running Windows 7 Home Premium 64-bit

like image 409
DMEM Avatar asked Jan 03 '14 15:01

DMEM


People also ask

Why can't I edit hosts file?

Run Notepad as administrator To modify your hosts file, you will need to first run Notepad (or any other text editor available to you on the same computer) as administrator. This is because the hosts file is a system file and cannot be modified without elevated privileges.

Can't edit hosts file Windows 11?

You'll need to run Notepad as administrator to edit the hosts file. To do this on Windows 10, click the start button, type “notepad” into the search bar, and then on the right, click “Run as administrator.”


2 Answers

You have to run notepad++ (or your favorite text editor) as an administrator. Right click notepad++ and it should display an option to run it as admin. Once open, locate the hosts file and open it with notepad++.

Windows hosts file location: c:\windows\system32\drivers\etc

Note: copy and paste the above url in the file-explorer when opening a file within notepad++ instead of locating it manually as some directories are hidden.

If the above doesn't work, Windows 10, 8 sometimes requires you to first turn off your antivirus.


If you require editing the hosts file often, you could look into third-party freeware tools to aid you. [1][2]

like image 191
C_B Avatar answered Sep 30 '22 05:09

C_B


This works: For Windows 7 and Windows Vista

Click Start -> All Programs -> Accessories. Right click on Notepad and select Run as administrator. Click Continue on the "Windows needs your permission" UAC window. When Notepad opens Click File -> Open. In the filename field type the file location, i.e.:

C:\Windows\System32\Drivers\etc\hosts

Click Open. Make the necessary changes to the hosts file. Click File -> Save to save your changes.

like image 45
ClareC Avatar answered Sep 30 '22 06:09

ClareC