4

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.

Marco
  • 158
  • 1
  • 1
  • 9
  • on which port your iis daemon is running? 32843 is this port is allowed on your server firewall? – Abhishek Anand Amralkar Nov 29 '13 at 09:28
  • The server firewall is deactivated; but the appropriate rules are specified. But this is not about the ports, but the fact that localhost does not work - on any port – Marco Nov 29 '13 at 09:29
  • Does the machine have multiple IP adresses? I had the problem and had to set localhost to point to a specific IP address in the hosts file to get it to work. – UnusualMutant Jan 31 '14 at 10:06

3 Answers3

9

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
  • 1
    Links to external resources are encouraged, but you should include contextual information with the link so that other users will have some idea what it is and how it relates to the topic. Always quote the most relevant part of the external resource as its URL may change or go permanently offline. See [Are answers that just contain links elsewhere really “good answers”?](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers) – Anthony Geoghegan Jan 06 '16 at 11:12
  • I hoped stackoverflow is not an external url for serverfault =) Will update the answer now – Uladzimir Shchur Jan 06 '16 at 11:32
  • I wouldn't really call stackoverflow external either but in general it's best for answers to be as self-contained as possible. That's a much better answer now (Upvoted - though I'd have probably kept the original link as "Please, check this answer" doesn't make sense any more) . – Anthony Geoghegan Jan 06 '16 at 12:11
  • This solution fixed my problem too. We experianced this issue by executing an npm command to generate a client from open-api. We always received the error "ECONNREFUSED 127.0.0.1:8000". Instead we could access the open-api spec with localhost:8000. So Thank you very much! – wami Jun 22 '21 at 12:34
1

This is an old case but I wanted to record my trials and tribulations somewhere that might help someone in the future.

I was working on a system where I had code on a handheld device communicating with a webservice on my local development PC. The handheld device was getting a HTTP Bad Request response from the web service so I installed Fiddler to see if I could identify the problem. It worked fine and the problem was fixed.

However then I found that once I removed Fiddler and cleared out the proxy settings it had added I could no longer connect to my webservice using http://192.168.0.192 which is my local IP. However http://localhost did work which meant that IIS was running.

This did my head in for a week before I discovered a suggestion that I do

netsh http delete iplisten ipaddress=127.0.0.1

Suddenly http://192.168.0.192 was working again but now http://localhost did not work. Further searching suggested I try

netsh http add iplisten 127.0.0.1

Although this seemed to be the reverse of what I had previously done I tried it and now both http://192.168.0.192 and http://localhost work ok

Thanks to all those people whose suggestions I tried.

bjoster
  • 4,423
  • 5
  • 22
  • 32
1

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

Your service is bound only on 172.16.2.187 and not to the loopback addresses (127.0.0.1, ::1:). You need to reconfigure IIS to listen on the loopback address of your choice, either IPv4 or IPv6, or listen on all available addresses (0.0.0.0) as appropriate.