14

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.

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

Windows allows 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 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

  • 1
    Do you have a citation for this? The TechNet page linked to by CodingPenguins does not appear to support your statement. – a CVn Jun 24 '15 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 '15 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"? – a CVn Jun 24 '15 at 18:18
0

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
    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. – a CVn Jun 24 '15 at 17:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.