IIS refuses connection to localhost and 127.0.0.1

iis-7localhostwindows-server-2008-r2

I am unable to connect to localhost and http:// 127.0.0.1 on one of my machines. However http://machinename works.

This results in the Windows Token Application being not able to issue tokens, because it can't connect.

This is showing up in the event log:

Request for security token failed with exception: 
System.ServiceModel.EndpointNotFoundException: Could not connect to 
http:// localhost : 32843/SecurityTokenServiceApplication/securitytoken.svc/actas. 
TCP error code 10061: No connection could be made because the target machine actively 
refused it 127.0.0.1:32843

I am able to ping to localhost:

Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

likewise for 127.0.0.1

Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

The hosts file is unaltered and has no active entry in it.

After issuing the netstat -ao | findstr LISTENING command in Powershell I found these 2 entries:

TCP 172.16.2.187:32843 machine:0 LISTENING 4
TCP 172.16.2.187:32844 machine:0 LISTENING 4

which look ok and indicate that the service is up and running. In addition, every Application pool is up and the websites are running and also accessible from the outside (read our LAN).

If you need additional information please ask for them in the comments and I will add them to this post.

Please help me in finding the missconfiguration.
Kind regards.

Best Answer

I've had the same problem, but localhost worked because ::1 address was listening as well as network ip. This command helped me

netsh http add iplisten 127.0.0.1