You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stream_socket_get_name() can return ipv6 address even when ipv6 is not available #16117
I chased the code path since I was looking at PHP network stuff a bit ago, and it (through a ton of indirection) basically just does getsockname then calls inet_ntop on it based on the returned sockaddr's address family. There's not much additional smarts in that code path other than getting the underlying socket fd for the stream. I'm feeling this might be DNS. Probably, it resolves localhost as ::1 and tries making the socket and connecting to that, even if (for some reason) it can't.
I just had a look and it's like @NattyNarwhal said. It seems to me like an issue with the system resolver or more it's configuration - in the pipeline case possible related to virtualization setup. I have no idea what we could do about this and don't really think this should be addressed in PHP. Or at least I cannot thing about any reasonable solution. As such I'm going to close this but if anyone has some reasonable idea what to do here, happy to re-open it.
Hmm the OP says that it returned ::1 but that's really strange becuase IPv6 is in brackets and that should be only on systems supporting IPv6 (check for HAVE_IPV6) so it would need to somehow return it from IPv4 family.
This certainly need more info about how to recreate and note what the exact output is.
Activity
NattyNarwhal commentedon Sep 30, 2024
I chased the code path since I was looking at PHP network stuff a bit ago, and it (through a ton of indirection) basically just does
getsocknamethen callsinet_ntopon it based on the returnedsockaddr's address family. There's not much additional smarts in that code path other than getting the underlying socket fd for the stream. I'm feeling this might be DNS. Probably, it resolveslocalhostas::1and tries making the socket and connecting to that, even if (for some reason) it can't.bukka commentedon Jun 21, 2025
I just had a look and it's like @NattyNarwhal said. It seems to me like an issue with the system resolver or more it's configuration - in the pipeline case possible related to virtualization setup. I have no idea what we could do about this and don't really think this should be addressed in PHP. Or at least I cannot thing about any reasonable solution. As such I'm going to close this but if anyone has some reasonable idea what to do here, happy to re-open it.
bukka commentedon Jun 21, 2025
Hmm the OP says that it returned ::1 but that's really strange becuase IPv6 is in brackets and that should be only on systems supporting IPv6 (check for HAVE_IPV6) so it would need to somehow return it from IPv4 family.
This certainly need more info about how to recreate and note what the exact output is.