26

I have a hosts file on Windows 7 that has an IP address followed by 10 different hostname aliases. I can ping the first nine, but if I try to ping the tenth, I get:

Ping request could not find host tenth. Please check the name and try again.

I've tried switching the ninth and tenth entry in case it was something to do with the specific hostname, in each case it is the tenth listed that I can't contact.

Is there a limit to the number of hostnames that can be listed on a line? If so, is there a way around this restriction?

EDIT: The length of this line of the hosts file is less than 150 characters.

1
  • Upvote for showing on the first page of Google results. June 2018
    – SDsolar
    Jun 7, 2018 at 4:05

2 Answers 2

34

Windows allows up to nine aliases per line. For more, add another line.

Before (h10 and h11 do not resolve):

127.0.0.1  h01 h02 h03 h04 h05 h06 h07 h08 h09 h10 h11

After (h10 and h11 resolve):

127.0.0.1  h01 h02 h03 h04 h05 h06 h07 h08 h09
127.0.0.1  h10 h11

I confirmed this behavior and workaround on Windows 7, Windows 10, and Windows Server 2008 R2.

While I cannot find a Microsoft citation, the following article claims the third-party utility Hosts Optimizer puts "a maximum of nine host names in a single line if they point to the same IP address."

http://www.ghacks.net/2010/05/23/windows-hosts-file-optimizer

3
  • 2
    Do you have a citation for this? The TechNet page linked to by CodingPenguins does not appear to support your statement.
    – user
    Jun 24, 2015 at 17:23
  • The TechNet page doesn't mention the nine alias maximum. I tried a tenth alias and it didn't work, and moving the tenth alias to the second line did work.
    – Steven
    Jun 24, 2015 at 17:37
  • Well, personal experience is worth something too, particularly when spelled out as such. But did you switch places between the "before" and "after"?
    – user
    Jun 24, 2015 at 18:18
2

Looks like Microsoft has inconsistent handling of the hosts file. While you can't ping past the ninth hosts item, you can still navigate to hosts past the tenth in the browser.

Documentation found related: https://technet.microsoft.com/en-us/library/bb727005.aspx?f=255&MSPPError=-2147217396#EDAA

You can just add additional lines.

127.0.0.1 myreallylonghostname
127.0.0.1 myotherreallylonghostname
1
  • 2
    While it's not impossible given the question, I find it hard to believe that the OP really has a host name of >255 characters without mentioning that. The linked page does not appear to say anything about maximum line length, and the OP does say already tried switching places of ninth and tenth but still couldn't resolve tenth.
    – user
    Jun 24, 2015 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .