Skip to content

Can not resolve "localhost" if not Network adapter exists #4988

@diridari

Description

@diridari

Describe the bug
On a Windowos PC without network adapter (tried in Windows Sandbox with disabled network adapter) poco throws a "Host not found" exception.
for:

  • Poco::Net::DNS::resolve("localhost");
  • Poco::Net::DNS::thisHost();

To Reproduce
Execute application in Windows Sandbox with deacitivated network adapter. (might be reproducable in docker)

try
{
    auto c = Poco::Net::DNS::resolve("localhost");
}
catch(Poco::Exception & e)
{
    std::cout << "localhost: " << e.what() << std::endl;
}
try
{
    auto c = Poco::Net::DNS::resolve("127.0.0.1");
}
catch(Poco::Exception & e)
{
    std::cout << "127.0.0.1: " << e.what() << std::endl;
}
try
{
    auto c = Poco::Net::DNS::thisHost();
}
catch(Poco::Exception & e)
{
    std::cout << "thisHost: " << e.what() << std::endl;
}

localhost: Host not found
127.0.0.1: Host not found
thisHost: Host not found

Expected behavior
Localhost should be resolvable. E.g. to 127.0.0.1 or ::1

Please add relevant environment information:

  • Wind 11
  • POCO 1.13.4

Additional context

ipconfig /all
Windows IP Configuration
   Host Name . . . . . . . . . . . . : <>
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Mixed
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
  • GetAdaptersInfo() returns 232 (ERROR_NO_DATA No adapter information exists for the local computer.)
  • getaddrinfo() returns 11004 ( WSANO_DATA see )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions