大网数据广告活动
网络与域名解析

GetAddrInfo fails with WSAHOST_NOT_FOUND (11001) error when there was a previous call for the AF_INET6 family in Windows

· 52CE 我爱测

Address an issue in which you receive a WSAHOST_NOT_FOUND error when the GetAddrInfo is called after another call for the AF_INET6 family.

This article addresses an issue in which you receive a WSAHOST_NOT_FOUND error when the GetAddrInfo is called after another call for the AF_INET6 family.

Applies to:   Windows 10 - all editions
Original KB number:   4057932

Symptoms

Consider the following scenario:

  • You use a flat name without any suffixes to run a query for a host name.
  • You have a suffix search list, and this host name is resolvable through one of these suffixes other than the last suffix in the list.
  • You run GetAddrInfo for the AF_INET6 family first, and then you run that command for the AF_INET family.

In this scenario, the function can't resolve the provided host name, and you receive the " WSAHOST_NOT_FOUND (11001)" error message.

For example, you have the following environment:

  • Suffix Search List: contoso.com, foo.contoso.com, bar.contoso.com
  • Host name trying to be resolved: test
  • Host DNS A record present in: foo.contoso.com

When you try to run the following sample code, the calls fail with the 11001 error.

hints.ai_socktype = SOCK_STREAM;
                hints.ai_protocol = IPPROTO_TCP;
                hints.ai_flags = 0;
                hints.ai_family = AF_INET6;
getaddrinfo("test", NULL, &hints, &res)
hints.ai_family = AF_INET;
getaddrinfo("test", NULL, &hints, &res)

Workaround

This issue can be avoided by using the following methods. The issue will not occur if you:

  • Use AF_UNSPEC for the family and let our code determine the A/AAAA results for you.
  • Put the suffix with the matching host A record as the last entry in the suffix search list.
  • Disable negative caching on the DNS client.
  • Pass the fully qualified host name to be resolved.

The first option is the recommended method, as there's usually no need to do the calls on a per family basis, and Windows is much better optimized to return the best possible set of results for both families.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
- Supported versions of Windows Server · Source date 02/12/2026
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。