search
HomeComputer TutorialsTroubleshootingHow to restore the deleted hosts file

Title: How to restore the hosts file after deletion

Abstract: The hosts file is a very important file in the operating system and is used to map domain names to IP addresses. If you accidentally delete the hosts file, you may be unable to access certain websites or have other network problems. This article will introduce how to recover accidentally deleted hosts file in Windows and Mac operating systems.

Text:
1. Restoring the hosts file in the Windows operating system
The hosts file in the Windows operating system is located in the driversetc folder under the system folder. The specific path is C:WindowsSystem32driversetc. Follow the steps below to recover accidentally deleted hosts file.

1. Start Windows Explorer and navigate to the C:WindowsSystem32driversetc folder.
2. Right-click a blank area in the folder, select "New" > "Text Document", and name it hosts.
3. Double-click the newly created hosts file and select "Notepad" or other text editor to open it.
4. Paste the following content in the hosts file:

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

Note: The above content is the basic content in the default hosts file. If you have customized the hosts file before, you need to copy and paste the backup contents line by line into the newly created hosts file to ensure that the previously performed domain name mapping still takes effect.

5. Save and close the hosts file.
6. Restart the computer.

2. Restore hosts file in Mac operating system
The hosts file in Mac operating system is located in the /private/etc folder and can be restored according to the following steps.

1. Open the "Terminal" application. You can find it in the Applications folder, or search for and open it using Spotlight (press Command Space and then type Terminal).
2. Enter the following command in the terminal window and press Enter:

sudo nano /private/etc/hosts

3. Enter your administrator password and press Press the Enter key to confirm.
4. In the editor that opens, copy and paste the following content into the hosts file:



Host Database

# # localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.

## 127.0.0.1 localhost

Note: The above content is the basic content in the default hosts file. If you have customized the hosts file before, you need to copy and paste the backup content line by line into the hosts file to ensure that the previously performed domain name mapping still takes effect.


5. Press "Control X" to exit the editor, then press the "Y" key to save the changes, and finally press the Enter key to confirm the saved file name.

6. Restart your Mac computer.


Summary:

Whether it is a Windows or Mac operating system, after accidentally deleting the hosts file, you can restore it by creating a new file and pasting the default or backup content into it. However, in order to avoid problems caused by deleting or tampering with the hosts file, it is recommended to back up the hosts file before making any changes so that it can be restored if needed. In addition, if you are not familiar with the use and editing of hosts files, it is best to avoid changing the contents at will to avoid unnecessary trouble. ###

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

Statement
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
How to fix OneDrive error 0x8004de20 in Windows?How to fix OneDrive error 0x8004de20 in Windows?Apr 15, 2025 am 12:00 AM

Microsoft OneDrive is the default cloud storage for Windows users, depending on it for file syncing between devices and keeping important documents saved in the

How to fix Microsoft account login error 0x80048820 in Windows?How to fix Microsoft account login error 0x80048820 in Windows?Apr 14, 2025 pm 10:00 PM

Error code 0x80048820 is a Windows-specific error that will typically pop up when users attempt to log in using their Microsoft account usually aiming at servi

Schedule 1 Dealer Not Working, See a Pro Guide with Top 7 FixesSchedule 1 Dealer Not Working, See a Pro Guide with Top 7 FixesApr 14, 2025 pm 08:09 PM

Troubleshooting Schedule 1 Dealer Issues: A Comprehensive Guide A malfunctioning Schedule 1 dealer can be incredibly frustrating. This guide provides multiple solutions to get your drug empire back on track. Schedule 1 Dealer Not Selling: The Problem

Alert: Do Not Delete the New inetpub Folder in Windows 11Alert: Do Not Delete the New inetpub Folder in Windows 11Apr 14, 2025 pm 08:08 PM

Windows 11 KB5055523 Update and the Mysterious inetpub Folder: Should You Worry? After installing the April 2025 Patch Tuesday update (KB5055523) on your Windows 11 (version 24H2) system, did a new inetpub folder suddenly appear on your C: drive? Th

Discord Loading Chunk Failed: Fix with 4 Useful WaysDiscord Loading Chunk Failed: Fix with 4 Useful WaysApr 14, 2025 pm 08:03 PM

Discord Loading Scramble Error: Four Practical Solutions Discord loading failure issues plagued many users. This article will provide four effective solutions to help you quickly get rid of this problem! Method 1: Refresh Discord Simple refresh operations can often solve some minor problems. On the stuck interface, press Ctrl R (Windows) or CMD R (Mac) to refresh Discord and try to reconnect to the server. If it does not work, try the following method. Method 2: Task Manager ends the Discord process If Discord is completely unresponsive, force the relevant process to end: Step 1: Press Ct

5 Useful Methods to Fix File Unreadable Google Drive5 Useful Methods to Fix File Unreadable Google DriveApr 14, 2025 pm 08:02 PM

This guide tackles the frustrating "file unreadable Google Drive" error. We'll explore potential causes and offer six practical solutions. Quick Navigation: Fix 1: Internet Connection Check Fix 2: Google Drive Server Status Fix 3: File Si

Fixes for SFC.DLL Is Either Not Designed to Run on WindowsFixes for SFC.DLL Is Either Not Designed to Run on WindowsApr 14, 2025 pm 08:01 PM

Encountering the error "SFC.DLL is either not designed to run on Windows"? This guide provides solutions to resolve this frustrating issue, which often appears after startup or when launching specific programs. Quick Navigation: Understand

How to fix KB5055613 fails to install in Windows 11?How to fix KB5055613 fails to install in Windows 11?Apr 14, 2025 pm 08:00 PM

The KB5055613 update, which was a Preview update for Windows 11 version 24H2, was released on April 11, 2025, in the Beta Channel for Windows Insiders, updating

See all articles

Hot AI Tools

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.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools