亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Table of Contents
?? 2. Fix the Hosts File on Windows
Step-by-step:
? 3. Fix the Hosts File on macOS
? 4. Fix the Hosts File on Linux
Optional: Restore from a Known-Good Backup
Home Common Problem How to fix a corrupted hosts file

How to fix a corrupted hosts file

Aug 01, 2025 am 12:10 AM

A corrupted hosts file can cause website loading issues or incorrect redirects; the fix involves restoring it to its default state with only localhost entries. 2. On Windows, open Notepad as administrator, navigate to C:\Windows\System32\drivers\etc\, edit the hosts file by removing suspicious entries and keeping only "127.0.0.1 localhost" and "::1 localhost", save the file, then run "ipconfig /flushdns" in an admin Command Prompt. 3. On macOS, open Terminal, run "sudo nano /etc/hosts", remove unwanted lines while preserving the localhost entries, save with Ctrl O and exit with Ctrl X, then flush the DNS cache using "sudo dscacheutil -flushcache" and "sudo killall -HUP mDNSResponder" for newer versions. 4. On Linux, use "sudo nano /etc/hosts" to edit the file, clean it to retain only the essential localhost mappings, optionally keep "127.0.1.1 your-computer-name", save and exit, then flush the DNS cache via "sudo systemd-resolve --flush-caches" if using systemd-resolved or restart networking services. 5. Prevent future issues by avoiding untrusted software, using antivirus tools, backing up the clean hosts file, and checking it when connectivity problems arise; if a backup exists, restore it with proper permissions to ensure system stability.

How to fix a corrupted hosts file

A corrupted or misconfigured hosts file can cause issues like websites not loading, being redirected incorrectly, or certain services failing to connect. The hosts file is a simple text file used by your operating system to map hostnames (like google.com) to IP addresses — and if it's been altered by malware, software, or manual errors, it may need fixing.

How to fix a corrupted hosts file

Here’s how to fix a corrupted hosts file on Windows, macOS, and Linux.


? 1. Understand What a Clean Hosts File Should Look Like

Before making changes, know what a default (clean) hosts file contains:

How to fix a corrupted hosts file
# 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 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

That’s it — usually just two active lines mapping localhost to the IPv4 and IPv6 loopback addresses.

If your file has hundreds of entries, redirects to strange IPs, or blocks common domains (like google.com, microsoft.com), it may be corrupted or hijacked.

How to fix a corrupted hosts file

?? 2. Fix the Hosts File on Windows

Step-by-step:

  1. Open Notepad as Administrator

    • Press Start, search for Notepad.
    • Right-click > Run as administrator.
  2. Open the hosts file

    • In Notepad, go to File > Open.
    • Navigate to:
      C:\Windows\System32\drivers\etc\
    • Change file filter from "Text Documents (*.txt)" to "All Files".
    • Open the file named hosts (no extension).
  3. Clean the file

    • Delete any suspicious or unwanted entries.
    • Keep only:
      127.0.0.1       localhost
      ::1             localhost
    • Optionally, you can comment out bad lines with # instead of deleting them.
  4. Save the file

    • Click Save.
    • If you get a permission error, make sure Notepad is running as admin.
  5. Flush DNS cache

    • Open Command Prompt as admin.
    • Run:
      ipconfig /flushdns

? 3. Fix the Hosts File on macOS

Step-by-step:

  1. Open Terminal

    • Go to Applications > Utilities > Terminal.
  2. Edit the hosts file

    • Run:
      sudo nano /etc/hosts
    • Enter your password when prompted.
  3. Remove unwanted entries

    • Use arrow keys to navigate.
    • Delete any suspicious lines (e.g., redirects, blocked sites).
    • Ensure these lines are present:
      127.0.0.1       localhost
      ::1             localhost
  4. Save and exit

    • Press Ctrl O → Enter to save.
    • Press Ctrl X to exit.
  5. Flush DNS cache

    • On macOS Ventura or later:
      sudo dscacheutil -flushcache
      sudo killall -HUP mDNSResponder
    • On older versions, use:
      sudo killall -HUP mDNSResponder

? 4. Fix the Hosts File on Linux

Step-by-step:

  1. Open Terminal

  2. Edit the hosts file

    sudo nano /etc/hosts
  3. Clean the content

    • Remove any malicious or incorrect entries.
    • Keep the essential lines:
      127.0.0.1       localhost
      ::1             localhost
      127.0.1.1       your-computer-name  # (common on Ubuntu, optional)
  4. Save

    • Ctrl O to write out, Enter, then Ctrl X to exit.
  5. Flush DNS (depends on distro)

    • If using systemd-resolved:
      sudo systemd-resolve --flush-caches
    • On other systems, restart networking or use:
      sudo /etc/init.d/dns-clean restart

      ? 5. How to Prevent Future Corruption

      • Avoid sketchy software: Some adware or "optimizers" modify the hosts file.
      • Use antivirus tools: Regular scans can catch malware that alters system files.
      • Back up the hosts file: After cleaning, save a known-good copy.
      • Monitor changes: If websites suddenly stop working, check the hosts file first.

      Optional: Restore from a Known-Good Backup

      If you have a backup of a working hosts file, simply replace the current one:

      • Windows: Paste into C:\Windows\System32\drivers\etc\
      • macOS/Linux: Replace /etc/hosts with sudo cp backup_hosts /etc/hosts

      Make sure to set proper permissions afterward (usually readable by all, writable only by root/admin).


      Basically, fixing a corrupted hosts file comes down to editing it with admin/root privileges, removing bad entries, and flushing the DNS cache. It's not complex — but easy to overlook when troubleshooting network issues.

      The above is the detailed content of How to fix a corrupted hosts file. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to create a system restore point How to create a system restore point Jul 07, 2025 am 12:17 AM

System restore point setting methods include manual creation, dependency automatic creation, and management of storage space. 1. Manual creation requires system protection to enable in "Create Restore Point", allocate 5% disk space and click "Create" to name the restore point; 2. The system will automatically create restore points when installing updates or changing settings, but do not guarantee comprehensiveness; 3. The restore point occupies no more than 5% of the system disk space by default, and the old version will be automatically cleaned, and storage can be managed by adjusting the upper limit.

What is a firewall and how does it work What is a firewall and how does it work Jul 08, 2025 am 12:11 AM

A firewall is a network security system that monitors and controls network traffic through predefined rules to protect computers or networks from unauthorized access. Its core functions include: 1. Check the source, destination address, port and protocol of the data packet; 2. Determine whether to allow connections based on trust; 3. Block suspicious or malicious behavior; 4. Support different types such as packet filtering firewalls, status detection firewalls, application layer firewalls and next-generation firewalls; 5. Users can enable built-in firewalls through operating system settings, such as Windows Security Center or macOS system preferences; 6. The firewall should be used in combination with other security measures such as strong passwords and update software to enhance protection.

How to turn off wifi on my router remotely How to turn off wifi on my router remotely Jul 05, 2025 am 12:28 AM

If you want to remotely turn off the router Wi-Fi, you must first confirm whether the router supports remote management; if it does not support it, it can be achieved through a smart socket power outage; advanced users can also consider flashing in custom firmware. The specific steps are as follows: 1. Check whether the router has remote management functions, such as the manufacturer's supporting app or cloud management functions; 2. If it is not supported, purchase and set up a smart socket and remotely cut off power through its app; 3. For technical users, you can install firmware such as DD-WRT or OpenWRT to obtain remote control permissions. Different methods have their own advantages and disadvantages. Please weigh them according to your own needs when choosing.

How to fix VIDEO_TDR_FAILURE (nvlddmkm.sys) How to fix VIDEO_TDR_FAILURE (nvlddmkm.sys) Jul 16, 2025 am 12:08 AM

When encountering the blue screen error VIDEO_TDR_FAILURE(nvlddmkm.sys), priority should be given to troubleshooting graphics card driver or hardware problems. 1. Update or rollback the graphics card driver: automatically search and update through the device manager, manually install or roll back to the old stable driver using NVIDIA official website tools; 2. Adjust the TDR mechanism: Modify the TdrDelay value in the registry to extend the system waiting time; 3. Check the graphics card hardware status: monitor the temperature, power supply, interface connection and memory module; 4. Check system interference factors: run sfc/scannow to repair system files, uninstall conflicting software, and try safe mode startup to confirm the root cause of the problem. In most cases, the driver problem is first handled. If it occurs repeatedly, it needs to be further deepened.

How to stop a program from connecting to the internet How to stop a program from connecting to the internet Jul 07, 2025 am 12:12 AM

To prevent specific programs from being connected to the network can be achieved through system firewalls or third-party tools. 1. Windows users can use their own firewall, create new rules in the "outbound rules" to select the program path and set "block connection"; 2. Third-party tools such as GlassWire or NetBalancer provide graphical interfaces that are more convenient to operate, but pay attention to source reliability and performance impact; 3. Mac users can control networking permissions through the command line with pfctl or using LittleSnitch and other tools; 4. A more thorough way is to use the network outage policy. The whitelisting policy prohibits all programs from being connected to the network by default and only allows trusted programs to access. Although the operation modes of different systems are different, the core logic is consistent, and attention should be paid to the details of the path and scope of the rules taking effect.

Why do I get a User Account Control (UAC) prompt every time Why do I get a User Account Control (UAC) prompt every time Jul 13, 2025 am 12:12 AM

UAC frequently pops up because the running program requires administrator permissions or the system setting level is too high. Common reasons include installation of software, modifying system settings, running third-party tools and other operation triggers. If using an administrator account, UAC only confirms the operation and not blocks. The methods for reducing prompts include: canceling the program to run as an administrator, lowering the UAC notification level, using a standard user account, and starting the program through the task planner. It is not recommended to turn off UAC completely because it can effectively prevent malicious programs from tampering with the system. You can set the UAC to "notify only when the program changes the computer" to balance security and experience.

How to change your name on Facebook? How to change your name on Facebook? Jul 13, 2025 am 12:03 AM

The Facebook name change process is simple, but you need to pay attention to the rules. First, log in to the application or web version and go to "Settings and Privacy" > "Settings" > "Personal Information" > "Name", enter a new name, and save it; secondly, you must use your real name, it cannot be modified frequently within 60 days, it cannot contain special characters or numbers, and it cannot be impersonated by others, and the review does not pass the auxiliary verification such as uploading ID cards; it usually takes effect within a few minutes to 3 working days after submission; finally, the name change will not notify friends, the homepage name will be updated simultaneously, and the old name will still be displayed in the history record.

How to update wifi router firmware How to update wifi router firmware Jul 05, 2025 am 12:24 AM

Updating the wireless router firmware is necessary and easy to operate. 1. Updates can fix vulnerabilities, improve performance, and add functions; 2. Check and updates can be manually operated through the management interface; 3. During updates, you need to ensure stable power supply, use wired connections, avoid interruptions, and confirm model matching; 4. Some brands support automatic updates, and update once or twice a year.