2

I am missing my hosts file in Windows 8.1.  I couldn't find it in C:\Windows\System32\drivers\etc

Here is what I see in that location: hosts.ics, hosts.old, lmhosts.sam, networks, protocol and services.

How can I fix it?

Reg Edit
  • 4,671
  • 2
  • 17
  • 35
shuvroMithun
  • 19
  • 1
  • 6

2 Answers2

2

The default hosts file contains only comments and is not needed for normal system operation:

# 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 (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 handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

(Lines starting # are comments in a hosts file.)

If the file's not present, an event will be logged on startup in the Windows event log, but it won't stop anything working.

You can simply create a new, empty text file called hosts (see Editing hosts file on Windows 8), and if you want to add your own custom entries, just and add them to it (as shown in the example comments in the default hosts file, but without the # at the start of the line).

Reg Edit
  • 4,671
  • 2
  • 17
  • 35
  • Of course the `hosts` file is used for normal system operations, maybe you were thinking of `hosts.sam` in older versions of Windows. – Peter Hahndorf Jun 21 '15 at 10:39
  • 2
    @Peter, please re-read my answer--of course it's _used_ (if present), or why would I suggest adding custom entries to it! If it's missing, an event will be logged on startup, but that's all. So the OP needn't worry too much that the file's missing (although it would be better to reinstate it--I've edited my answer to this effect). – Reg Edit Jun 21 '15 at 11:13
  • Okay, you are right, it is not needed for normal OS operation, but it is checked for and used when found. Windows created `hosts.ics` an d renamed `hosts` to `hosts.old` for a reason. I think you should not have both `hosts.ics` and `hosts` at the same time – Peter Hahndorf Jun 21 '15 at 12:08
  • Are you sure `hosts.ics` is used when not using Internet Connection Sharing, @Peter? (See my comment to your answer.) What do the comments in that file say? I'm very much tempted to think you're wrong here, and Reg Edit is right: one can just create that `hosts` file if one needs it, and no need to worry if it's not there. – Arjan Jun 21 '15 at 12:46
  • @Arjan - There is an answer to a question on serverfault (http://serverfault.com/questions/452268/hosts-file-ignored-how-to-troubleshoot/630999#630999), it says when `hosts.ics` is there, `hosts` is ignored. I just added a `hosts.ics` file on my system and Windows seems to use both. But I don't have connection sharing enabled, so I don't know how that behaves. The fact that there is a `hosts.old` seem to indicate that you shouldn't have both. – Peter Hahndorf Jun 21 '15 at 13:00
  • 1
    Problem solved , I renamed the hosts.old file to hosts which is similar to hosts file – shuvroMithun Jun 22 '15 at 04:32
  • @shuvro: Welcome to Super User (and, yes, I know that you “joined” four months ago).  If you have found a way to solve your problem, you may post it as an “answer”, and I encourage you to do so.  You'll even be able to “accept” it, although you may need to wait a few hours (or days?) before you can do that. – G-Man Says 'Reinstate Monica' Jun 22 '15 at 06:43
-1

You have a hosts.ics file which if such file exists is used instead of the traditional hosts file.

You can verify this by adding a new entry to hosts.ics say

 127.0.0.1   my.test.local

and then ping my.test.local

Peter Hahndorf
  • 13,370
  • 9
  • 51
  • 67
  • I'm not on Windows, but isn't that file for Internet Connection Sharing? (Some OLD posts I find through Google even show that in the header of that file, when opening it in a text editor, including: *"This file has been automatically generated for use by Microsoft Internet Connection Sharing. It contains the mappings of IP addresses to host names for the home network. Please do not make changes to the HOSTS.ICS file. Any changes may result in a loss of connectivity between machines on the local network."*) – Arjan Jun 21 '15 at 11:21
  • From https://support.microsoft.com/en-us/kb/309642/en-us, which is old so maybe no longer accurate: *"The Hosts.ics file is used by ICS to store information about dynamically configured clients. Avoid making changes to this file to prevent the loss of connectivity or data. The Hosts file (with no file name extension) is the file to which you add information about statically configured clients."* – Arjan Jun 21 '15 at 13:01