Skip to content

Regression: Windows cannot connect to localhost without network #5357

Description

@pwuertz

On a Windows systems without network connection, aiohttp fails to connect to localhost services.
This problem is present in aiohttp 3.7, not in aiohttp 3.6.

I think I traced the problem to 9bce9c2, which added the flag AI_ADDRCONFIG to the getaddrinfo call.

On Windows10, Python 3.8, no network connection, this will throw:

import socket
socket.getaddrinfo('localhost', 1234, 0, socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG)

I can also reproduce this fail in a windows docker container started with --network none.

The documentation for this flag says:

If the AI_ADDRCONFIG bit is set, getaddrinfo will resolve only if a global address is configured.
If AI_ADDRCONFIG flag is specified,
IPv4 addresses shall be returned only if an IPv4 address is configured on the local system, and
IPv6 addresses shall be returned only if an IPv6 address is configured on the local system.
The IPv4 or IPv6 loopback address is not considered a valid global address.

So if localhost is your only IP address, AI_ADDRCONFIG is expected to fail even for localhost. It does seem to resolve on linux though.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions