How to Fix Empty Hosts File



Hosts file

What's hosts file?

The Hosts file is used by the operating system to convert human-friendly hostnames to numerical Internet Protocol (IP) addresses which identify and locate a host in an IP network.

Microsoft kept the hosts file alive in Windows networking which is why it varies very little whether used in Windows, macOS, or Linux. The syntax stays mostly the same across all platforms. Most hosts files will have several entries for loopback. We can use that for the basic example for the typical syntax.

The first part will be the location to redirect the address to, the second part will be the address that you will want to redirect, and the third part is the comment. They can be separated by a space, but for ease of reading are typically separated by one or two tabs.
 

How to Fix Empty Hosts File?


  • Press the Windows key.
  • Type Notepad in the search field.
  • In the search results, right-click Notepad and select Run as administrator.

  • From Notepad, open the following file as a text file: c:\Windows\System32\Drivers\etc\hosts.
  • Make the necessary changes to the file if it's empty copy and past the next into the opened file according to your windows.
  • Select File > Save to save your changes.

For windows 7:

# Copyright (c) 1993-2006 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 (such as these) 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 # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost

For windows 8:


# Copyright (c) 1993-2006 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 (such as these) 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 # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost

For windows 10:


# Copyright (c) 1993-2006 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 (such as these) 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 # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost