Skip to content
WindowsBeginner

Fixing Hosts File Saving as .TXT in Windows – Complete Technical Guide for System Administrators

The hosts file in Windows is a critical system file used for local DNS resolution. It allows administrators and developers to map domain names to specific IP...

BI
Bison Technical Team Enterprise IT specialists
Updated 09 Apr 2026 3 min read 177 total views

The hosts file in Windows is a critical system file used for local DNS resolution. It allows administrators and developers to map domain names to specific IP addresses without relying on external DNS servers.

However, one of the most common issues faced while editing this file is that it gets incorrectly saved as a .txt file, making it ineffective.

Advertisement

This article provides a complete technical explanation, root cause analysis, and step-by-step solutions to properly edit and save the hosts file without errors.


What is the Hosts File?

The hosts file is a plain text file without any extension located at:

C:\Windows\System32\drivers\etc\hosts

Key Functions:

  • Overrides DNS resolution
  • Used for:
    • Website blocking
    • Local development (e.g., pointing domains to localhost)
    • Testing server migrations
    • Security filtering


Common Problem: Hosts File Saving as .txt

Symptoms:

  • File gets saved as:

    hosts.txt
  • Changes do not take effect
  • DNS resolution remains unchanged


Root Causes

1. Default File Type Behavior

Windows Notepad automatically appends .txt when:

  • File type is set to Text Documents (*.txt)


2. Lack of Administrative Privileges

The hosts file is a protected system file, requiring elevated permissions.


3. Hidden File Extensions

Windows hides extensions by default, causing confusion between:

  • hosts (correct)
  • hosts.txt (incorrect)


4. Read-Only Attribute

The file may be set as read-only, preventing overwrite.


Step-by-Step Solution

Step 1: Open Notepad as Administrator

  • Search Notepad
  • Right-click → Run as administrator


Step 2: Open Hosts File Properly

  • File → Open
  • Navigate to:

    C:\Windows\System32\drivers\etc\
  • Change file type to:

    All Files (*.*)


Step 3: Edit the File

Example entries:

127.0.0.1   example.com
127.0.0.1   www.example.com
192.168.1.10   testserver.local


Step 4: Save Without .txt

Correct Method:

  • Press Ctrl + S (recommended)

Alternative (Save As):

  • File name:

    hosts
  • Save as type:

    All Files (*.*)


Fixing Already Saved .txt File

Method 1: Rename File

  1. Enable:
    • View → File name extensions
  2. Rename:

    hosts.txt → hosts
  3. Confirm system warning


Method 2: Copy Replace

  • Copy correct file into:

    C:\Windows\System32\drivers\etc\
  • Replace existing file (Admin rights required)


Additional Troubleshooting

Issue: Access Denied

✔ Solution:

  • Ensure Notepad is running as Administrator


Issue: File Not Updating

✔ Flush DNS:

ipconfig /flushdns


Issue: Antivirus Blocking

✔ Temporarily disable antivirus or add exception


Issue: Read-Only File

✔ Fix:

  • Right-click → Properties → Uncheck Read-only


Best Practices

  • Always backup hosts file before editing
  • Use Ctrl + S instead of Save As
  • Keep entries clean and documented
  • Avoid duplicate entries
  • Use comments:

    # Block social media
    127.0.0.1 facebook.com


Advanced Use Cases

1. Website Blocking

127.0.0.1 youtube.com


2. Local Development

127.0.0.1 myproject.local


3. Testing DNS Changes

192.168.0.50 staging.website.com


Conclusion

The issue of the hosts file saving as .txt is primarily caused by incorrect save settings and lack of administrative permissions. By following proper steps—especially using "All Files" option and admin privileges—you can ensure the file remains valid and functional.

Understanding this small but critical detail can save significant troubleshooting time in networking, development, and system administration tasks.


#Windows #HostsFile #Networking #DNS #SystemAdmin #ITSupport #WindowsTips #TechGuide #Troubleshooting #FileExtension #Notepad #AdminRights #Windows10 #Windows11 #Localhost #WebDevelopment #DNSOverride #NetworkingBasics #SysAdminTips #TechSupport #FileManagement #WindowsFix #DeveloperTools #IPConfig #FlushDNS #NetworkIssues #SystemFiles #ProtectedFiles #WindowsErrors #FixGuide #HowTo #TechHelp #ITGuide #WindowsAdmin #ConfigFiles #LocalServer #Debugging #DNSIssues #InternetControl #WebsiteBlocking #HostsFileFix #WindowsSecurity #AntivirusIssue #FilePermissions #SystemConfiguration #NetworkSetup #ITSolutions #TechArticle #AdvancedWindows #ComputerTips

YOUR FEEDBACK

Was this guide useful?

Your answer helps us keep BISONKB accurate and practical.

BISON AI

Ask about “Fixing Hosts File Saving as .TXT in Windows – Complete Technical Guide for System Administrators”

This interface is ready to connect to your preferred AI provider. No article or user data is sent until that service is configured.

THE BISON BRIEF

Practical IT knowledge, once a week.

New troubleshooting guides, scripts and infrastructure notes. No noise.

By subscribing, you agree to our privacy policy.