Share via

How to can edit the file hosts in Windows?

INFORMATICA-CORASCO 20 Reputation points
2025-12-10T21:53:15.1833333+00:00

I try edit the file hosts but the i can't edit the file.

I open the file from notepad like sysadmin but i can't save the file.

How to can edit this file?

Windows for home | Windows 11 | Files, folders, and storage
0 comments No comments

3 answers

Sort by: Most helpful
  1. _AW_ 67,426 Reputation points Volunteer Moderator
    2025-12-10T23:40:43.2066667+00:00

    Any app that needs to edit the hosts file needs to be run elevated. To do this with Notepad:

    Press the Windows key + R to bring up the run box

    Copy and paste in the following command: Notepad.exe C:\Windows\System32\Drivers\etc\hosts

    Hold down the Ctrl + Shift keys and press "OK"

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Anonymous
    2025-12-10T22:30:38.0166667+00:00

    Hi INFORMATICA-CORASCO, I know it can be really frustrating when youre just trying to make a simple change to the hosts file and Windows keeps blocking you it feels like something that should be easy.

    Saving the hosts file can fail because it’s read only blocked by UAC or antivirus or opened without elevation so the fix is to remove the read only attribute with attrib -r then open it using elevated PowerShell Start-Process notepad.exe … -Verb RunAs then temporarily disable Tamper Protection if needed use a command line append for quick edits and restore permissions afterward for security.

    When you tried editing the hosts file did you check if it was marked as read only or if antivirus Tamper Protection was enabled?

    Best regards

    Lucky

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2025-12-10T21:53:25.2633333+00:00

    To edit the hosts file in Windows, you need to ensure that you have the necessary permissions. Here are the steps you can follow:

    1. Run Notepad as Administrator:
      • Click on the Start menu, type Notepad, right-click on it, and select Run as administrator. If prompted, enter your administrator password or confirm the action.
    2. Open the Hosts File:
      • In Notepad, go to File > Open. Navigate to the following path: C:\Windows\System32\drivers\etc\. Make sure to change the file type from "Text Documents (.txt)" to "All Files (.*)" to see the hosts file.
      • Select the hosts file and click Open.
    3. Make Your Changes:
      • Edit the hosts file as needed.
    4. Save the File:
      • After making your changes, go to File > Save to save the file.

    If you still encounter issues saving the file, ensure that you are running Notepad with administrative privileges as described above. If you receive an error message stating that access is denied, it may indicate that your user account does not have the required permissions, or that another process is using the file.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.