Share via

Issue with DNS lookups and Chinese characters in hostname

Bryan Johnson 20 Reputation points
2026-02-24T01:58:29.8166667+00:00

I am seeing an issue in the field, and I'd like the communities take on it. When the hostname is Chinese characters, our logging show this error when our application runs (I havent tried a hostname of ascii and chinese).

=====

2026/2/23 16:38:12: (6) Exception occurred executing operation: 不知道这样的主机。

2026/2/23 16:38:12: (6) Exception occurred executing operation: 在 System.Net.Dns.GetAddrInfo(String name)

在 System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)

在 System.Net.Dns.GetHostEntry(String hostNameOrAddress)

在 System.Runtime.Remoting.Channels.CoreChannel.GetMachineName()

在 System.Runtime.Remoting.Channels.CoreChannel.GetMachineIp()

在 System.Runtime.Remoting.Channels.Http.HttpServerChannel.SetupMachineName()

在 System.Runtime.Remoting.Channels.Http.HttpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider)

在 System.Runtime.Remoting.Channels.Http.HttpChannel..ctor(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)

=====

So basically, our client creates an HttpChannel object and registers it. With ascii host names, this seems to work just fine, but when the hostname is is Chinese characters it blows up like the above.

I've tried these two standalone snippets from the stack:

  1. Dns.GetHostEntry(Environment.MachineName) // Environment.MachineName has chinese characters, this doesn't fail
  2. Dns.GetHostEntry(Dns.GetHostName()) // this fails

From what I can tell through additional debug statements, Dns.GetHostName() returns "???" (the actual literal ascii values of 63).

I believe the problem stems from the requirement that DNS is compatible with ascii hostname (per various RFCs).

Since our code needs the HttpChannel, what are my options?

I will note that the IDictionary parameter in our current invocation of the HttpChannel c'tor is null. So I tried creating a dictionary with a "machineName" entry with the value of Enviornment.MachineName. Is that a valid workaround?

Developer technologies | .NET | .NET Runtime
0 comments No comments
{count} votes

Answer accepted by question author
  1. Jack Dang (WICLOUD CORPORATION) 14,955 Reputation points Microsoft External Staff Moderator
    2026-02-24T03:14:33.9366667+00:00

    Hi @Bryan Johnson ,

    Thanks for reaching out.

    Even though Windows allows a machine name to contain Chinese characters (and Environment.MachineName can return it correctly in Unicode), DNS resolution is still fundamentally ASCII-based. When Dns.GetHostName() is called, the networking layer attempts to return a DNS-compatible hostname. If proper IDN (punycode) handling isn’t applied, the non-ASCII characters can get converted to "???", which then causes Dns.GetHostEntry() to fail with “No such host is known.”

    Regarding your workaround:

    Creating an IDictionary and setting "machineName" to Environment.MachineName

    This can work in some cases, but it’s not guaranteed. If the remoting stack still performs DNS resolution on that value and it contains non-ASCII characters, you may hit the same issue again. So it’s more of a partial workaround than a fully reliable fix.

    Practically speaking, your safest options are:

    1. Rename the machine to an ASCII-only hostname (recommended): This aligns with DNS expectations and avoids encoding issues entirely.
    2. Configure the channel using a fixed IP address instead of relying on hostname resolution. This bypasses DNS and avoids the character encoding problem.

    Longer term, since this is using .NET Remoting (HttpChannel), it’s worth noting that the technology is legacy and can be sensitive to environmental quirks like this. If modernization is an option, moving to WCF, gRPC, or ASP.NET Core-based communication would eliminate this category of issue altogether.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.


1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-02-24T01:58:39.62+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The issue you're experiencing with DNS lookups for hostnames containing Chinese characters likely stems from the limitations of traditional DNS, which is primarily designed to work with ASCII characters as per various RFCs. When you use Dns.GetHostName(), it seems to return a placeholder ("???") for the Chinese characters, indicating that it cannot properly resolve the hostname to an ASCII-compatible format.

    In your case, since Dns.GetHostEntry(Dns.GetHostName()) fails while Dns.GetHostEntry(Environment.MachineName) works, it suggests that the problem lies in how the hostname is being resolved when it contains non-ASCII characters.

    One potential workaround is to use the Environment.MachineName directly, as you mentioned, by creating a dictionary with a "machineName" entry containing Environment.MachineName. This approach should allow you to bypass the issue with the DNS resolution of the hostname containing Chinese characters, as it directly uses the valid machine name.

    Additionally, consider the following options:

    1. Use Fully Qualified Domain Names (FQDN): If possible, use FQDNs that are ASCII-compatible.
    2. Check DNS Configuration: Ensure that your DNS server supports internationalized domain names (IDNs) if you need to work with non-ASCII characters.
    3. Handle Exceptions Gracefully: Implement error handling to manage cases where DNS lookups fail, potentially falling back to alternative methods of obtaining the machine's IP address.

    These steps should help mitigate the issues you're facing with DNS lookups involving Chinese characters.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.