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
Open an TCP server on some local port of the IPv4 loopback interface. For example, with Python 3 run a simple HTTP server with python -m http.server --bind 127.0.0.1 8000.
In another terminal, run Test-Connection localhost -TcpPort 8000.
Expected behavior
The command returns True.
Actual behavior
The command returns False.
If we run Test-Connection 127.0.0.1 -TcpPort 8000 or Test-Connection localhost -IPv4 -TcpPort 8000, the returned result is True. The command Test-NetConnection localhost -Port 8000 does give the correct answer, although it first tries connecting to ::1 : 8000 and fails.
Error details
It seems Test-Connection is just testing the first loopback address it is finding, which is the IPv6 ::1 address. I think this behaviour is surprising, especially since locally deployed servers are most frequently bound to 127.0.0.1 only.
Environment data
Name Value
---- -----
PSVersion 7.2.4
PSEdition Core
GitCommitId 7.2.4
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Prerequisites
Steps to reproduce
python -m http.server --bind 127.0.0.1 8000.Test-Connection localhost -TcpPort 8000.Expected behavior
The command returns
True.Actual behavior
The command returns
False.If we run
Test-Connection 127.0.0.1 -TcpPort 8000orTest-Connection localhost -IPv4 -TcpPort 8000, the returned result isTrue. The commandTest-NetConnection localhost -Port 8000does give the correct answer, although it first tries connecting to::1 : 8000and fails.Error details
It seems
Test-Connectionis just testing the first loopback address it is finding, which is the IPv6::1address. I think this behaviour is surprising, especially since locally deployed servers are most frequently bound to127.0.0.1only.Environment data
Visuals
No response