The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

EndpointPair.LocalHostName | localHostName property

Applies to Windows and Windows Phone

Get or set the local hostname for the EndpointPair object.


var localHostName = endpointPair.localHostName;
endpointPair.localHostName = localHostName;

Property value

Type: HostName

The local hostname for the EndpointPair object.


The LocalHostName property can contain a local hostname or an IP address.

The LocalHostName property can be set to one of the following:

  • The name of the local host that can be resolved by the Domain Name System (DNS) or by another namespace provider.
  • The name of the local host that matches a string in the following file on the local computer: %WINDIR%\\system32\drivers\etc\hosts
  • A string that contains an IPv4 or an IPv6 network address of the local host. An IPv4 address string is in dotted-decimal notation ("", for example). An IPv6 address is in hexadecimal notation ("21DA:00D3:0010:2F3B:02AA:00FF:FE28:9C5A", for example).

When this property is set to the "localhost" string, this represents all loopback addresses on the local computer.

The NetworkInformation.GetHostNames method in the Windows.Networking.Connectivity namespace can be used to retrieve a list of hostnames or IP addresses associated with the local machine. The LocalHostName property can then be set to one of these hostnames or IP addresses.

The LocalHostName property can also be set to null. If the LocalHostName property is null before a network connection is established by a client app, then the system will automatically provide the local IP address for the app to use.


Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8


Windows::Networking [C++]





See also




© 2014 Microsoft. All rights reserved.