Monday, January 23, 2012

Windows authentication fails when using hosts file IIS

You can use the hosts file (C:\Windows\System32\drivers\etc\hosts) to setup a mock host-name for local development/testing. Here is an example: I want to use http://helloworld/ locally to point to a test website.

1. Add an entry for helloworld to the hosts file.

This means that the url helloworld will be looped back to your local machine

2. Next in IIS Manager, right click on your site and select “Edit Bindings”

3. In the dialog that opens setup your default binding like so:


4. Browse to http://helloworld/

Now if you have Windows Authentication turned on, on your site, you will find that IE will not auto log you into the site, nor will you be able to log in by providing the correct credentials. The reason for this is  that in Windows Server 2003 SP1 a new security functionality called “loopback check” was added, this blocks the authentication request and so for your site to work with the new-host name locally you need to disable the loopback check.

This is described in this post:, and is done via editing the registry (2 methods are provided). Here is the first method (which I like better than method 2 – which completely disables the loopback check).

Method 1: individually allow host-names

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
  3. Right-click MSV1_0, point to New, and then click Multi-String Value.
  4. In the Name column, type BackConnectionHostNames, and then press ENTER.
  5. Right-click BackConnectionHostNames, and then click Modify.
  6. In the Value data box, type the CNAME or the DNS alias, that is used for the local shares on the computer, and then click OK.
    Note Type each host name on a separate line.
    Note If the BackConnectionHostNames registry entry exists as a REG_DWORD type, you have to delete the BackConnectionHostNames registry entry.
  7. Exit Registry Editor, and then restart the computer.
Method 2: disable loopback check
Copy the folllowing text into notepad, save the file with an extension of .reg and run it.

Windows Registry Editor Version 5.00


No comments: