Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF and 127.0.0.1 vs localhost

Tags:

wcf

localhost

Is there a different between using 127.0.0.1 vs localhost?

I ask this because I have noticed a difference when defining wcf connections.

<client>
  <endpoint binding="netTcpBinding" bindingConfiguration="netTcpNosecurity" contract="MyClass" name="MyName" behaviorConfiguration="megaGraphBehavior" address="net.tcp://localhost:8011/myname" />
</client>

In some environments i have noticed that a server suddenly starts throwing this error when using localhost and i can only make it work by using 127.0.0.1.

Could not connect to net.tcp://localhost:8011/myname. The connection attempt lasted for a time span of 00:00:02.2341176. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8011. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8011

How can this be explained and should i always use 127.0.0.1?

like image 252
Qwwwwwe Avatar asked Nov 06 '22 04:11

Qwwwwwe


1 Answers

Localhost by default references the IPv6 address on IPv6 enabled machines. Perhaps the server-side endpoint is only accessible via IPv4?

like image 106
Sander Avatar answered Nov 15 '22 13:11

Sander