Why does localhost not work on Windows Server 2008 R2?

30,795

Solution 1

Windows Server 2008 R2 with IIS 7.5 does not appear to add an IIS binding to localhost by default. You need to explicitly add a binding for localhost. For information on adding a binding to IIS see http://www.iis.net/configreference/system.applicationhost/sites/site/bindings/binding

Choosing to not add the binding you must access the site via machineName/siteName or any other configured binding such as www.contoso.com even when local.

Solution 2

By default, this is not blocked. Chances are you haven't enabled the exception for IIS in Windows Firewall. To test, you can disable the firewall all together. If that works, you should re enable it and then enable just the necessary rules.


Update: Reading your comment, it seems that what I mentioned above isn't the problem. If 127.0.0.1 works in the browser and localhost does not, chances are something (someone?) borked your default HOSTS file. Make sure that 127.0.0.1 localhost is in there. There's nothing magic about the word "localhost". It's just an entry in the default HOSTS file that points to 127.0.0.1.

Share:
30,795

Related videos on Youtube

Chris Marisic
Author by

Chris Marisic

I am the Principal Consultant of Marisic.NET specializing in user experience, software architecture, project design, and systems testing.

Updated on September 18, 2022

Comments

  • Chris Marisic
    Chris Marisic over 1 year

    Why does navigation to localhost not work on Windows Server 2008 R2? The expected result is the IIS application hosted on the machine in question to be returned. Navigation to localhost/mySite returns a 404 however using machineName/mySite returns the application as expected.

    Is there a way to fix this to allow localhost to properly work?

    What has already been attempted to no avail, modifying the registry:

    setting DWORD: DisableLoopbackCheck 1 at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0

    • TomTom
      TomTom over 12 years
      What do you mean it does not work? t works on my stock installed iwndows servers.
    • Ov's Pianist
      Ov's Pianist over 12 years
      Your description of how it doesn't work should ideally include: What you're trying to do; what the response is (you don't have a symptom listed right now); the program you're trying to do it in; what the server program you're using is; what you've tried (which you have in there); and any other relevant information; there's not a lot to go on here. Incidentally, Win2K8+ tends to go IPV6 first, so if there's no binding for ::1 (IPV6 localhost), that can be a problem. You've described authentication-related settings, but haven't demonstrated an authentication-related symptom. More info = better.
  • Chris Marisic
    Chris Marisic over 12 years
    This answer is not relevant to my question, will downvote soon.
  • MDMarra
    MDMarra over 12 years
    What exactly isn't relevant? It was entirely relevant, given the scant amount of detail in your original question. I then updated it when you commented on your own question with more details. Downvotes should be for wrong or misleading answers. Not for answers that make an attempt to answer a vague/incomplete question.
  • Chris Marisic
    Chris Marisic over 12 years
    The firewall answer makes no sense, and your edit occurred after my initial comment.
  • user1364702
    user1364702 over 12 years
    Machinename/site works, localhost/site doesn't...are you only binding to a particular IP address and not listening to 0.0.0.0 or 127.*?
  • user1364702
    user1364702 over 12 years
    If 127.0.0.1/site works but localhost/site doesn't, your name resolution could be screwed up. If neither works but machinename/site works, it could be server application binding to a particular interface.
  • MDMarra
    MDMarra over 12 years
    @ChrisMarisic It makes perfect sense. In your original question you didn't state that you could connect in any way. Logically, most people test using localhost before making DNS entries, so it's safe to assume (since you didn't say otherwise) that you couldn't connect at all. Then, when you commented that you could get there using the hostname, I edited my answer to make sure that your localhost-to-loopback mapping was happening properly, which is a valid suggestion given your problem. You might want to read How to Ask. It outlines why detailed questions are important to getting good answers.
  • Chris Marisic
    Chris Marisic about 9 years
    This answer still has nothing to do with this question