You may need to allow external access to the port in the firewall.
As long as you're communication from localhost
to localhost
, the firewall doesn't come into play, as these requests are handled by the loopback adapter.
But when communicating from localhost
to the machines IP address, you're making a network request that's handled by the firewall (even though you're still on the same machine physically).
By the way: For the server side it doesn't matter whether you start the WCF service with endpoint localhost
or 192.168.1.1
.
EDIT
I wrote that it doesn't matter whether you listen on localhost
or 192.168.1.1
- this is only true if you only have one network adapter available.
As soon as there are two or more network cards (for example: Wireless LAN is turned on and you're connected via cable), localhost
or 0.0.0.0
will make the service listen on any adapter. Using 192.168.1.1
will make the service listen only for connections on that IP address.
This is important to know especially in cases where the different network adapters become members of different (sub)networks.
For example: One adapter is connected to the 192.168.1
network and the other adapter is connected to the 192.168.2
network. If your service listens on localhost
or 0.0.0.0
it will be reachable from both networks. If it only listens on 192.168.1.1
, it will not be available for the 192.168.2
network.