IIS refuses connection to localhost and 127.0.0.1

Solution 1:

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

Solution 2:

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.

Solution 3:

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.