can't connect to cluster error due to port 52323 but it's not a local port
AnQueth opened this issue · 1 comments
Describe the bug
I am getting the error just trying to run from vs 2022. I have no service using 52323, this port is on the cluster from the dotnet-monitor sidecar so it's not my port on a local machine.
2024-04-19T19:09:52.3472113Z | MindaroCli | TRACE | Event: Command.Start {"properties":{"Arguments":"connect --namespace dotnettest --service dotnettest-service --context masked-aks --local-port 5142 --env c:\users\aaron\appdata\local\temp\tmpc1c.tmp.env --script c:\users\aaron\appdata\local\temp\tmpc2d.tmp --control-port 61545 --ppid 63656 --elevation-requests []","IsRoutingEnabled":"false"},"metrics":null}\nOperation context: {"clientRequestId":null,"correlationId":"7e1c4366-e70f-4647-b924-5d46217217c2:5a4f5f04c435","requestId":null,"userSubscriptionId":null,"startTime":"2024-04-19T19:09:52.2749416+00:00","userAgent":"LPK/3.2.20240123.7-27a8263e VisualStudio/17.9.34728.123","requestHttpMethod":null,"requestUri":null,"version":"1.0.20240122.2","requestHeaders":{},"loggingProperties":{"ApplicationName":"MindaroCli","DeviceOperatingSystem":"Microsoft Windows 10.0.22631","Framework":".NET 7.0.15","MacAddressHash":"e8b7b1639dbec2fb5c39f93f0e3f2cb44143c6d39610bbb04edf927daede8448","ProcessId":15452,"TargetEnvironment":"Production","CommandId":"5a4f5f04c435"}}
2024-04-19T19:09:52.3948929Z | MindaroCli | TRACE | Running Microsoft.BridgeToKubernetes.Exe.Commands.Connect.ConnectCommand...\nOperation context: {"clientRequestId":null,"correlationId":"7e1c4366-e70f-4647-b924-5d46217217c2:5a4f5f04c435","requestId":null,"userSubscriptionId":null,"startTime":"2024-04-19T19:09:52.2749416+00:00","userAgent":"LPK/3.2.20240123.7-27a8263e VisualStudio/17.9.34728.123","requestHttpMethod":null,"requestUri":null,"version":"1.0.20240122.2","requestHeaders":{},"loggingProperties":{"ApplicationName":"MindaroCli","DeviceOperatingSystem":"Microsoft Windows 10.0.22631","Framework":".NET 7.0.15","MacAddressHash":"e8b7b1639dbec2fb5c39f93f0e3f2cb44143c6d39610bbb04edf927daede8448","ProcessId":15452,"TargetEnvironment":"Production","CommandId":"5a4f5f04c435","TargetServiceName":"dotnettest-service","IsRoutingEnabled":false}}
2024-04-19T19:09:53.0964607Z | MindaroCli | TRACE | Remoting started listening on 61545
2024-04-19T19:09:59.0338522Z | MindaroCli | TRACE | Connection established.\n
2024-04-19T19:09:59.7626031Z | MindaroCli | WARNG | Port 52323 is already in use on your machine. Please free this port and try again. Use 'netstat -ano' command to find which program is using this port.
2024-04-19T19:09:59.7626625Z | MindaroCli | ERROR | Port 52323 is already in use on your machine. Please free this port and try again. Use 'netstat -ano' command to find which program is using this port.\n
2024-04-19T19:09:59.7628687Z | MindaroCli | TRACE | Stopping workload and cleaning up...\n
2024-04-19T19:10:00.5292117Z | MindaroCli | TRACE | Event: Command.End {"properties":{"Arguments":"connect --namespace dotnettest --service dotnettest-service --context masked-aks --local-port 5142 --env c:\users\masked\appdata\local\temp\tmpc1c.tmp.env --script c:\users\masked\appdata\local\temp\tmpc2d.tmp --control-port 61545 --ppid 63656 --elevation-requests []","Result":"Failed","FailureReason2":"Port 52323 is already in use on your machine. Please free this port and try again. Use \u0027netstat -ano\u0027 command to find which program is using this port."},"metrics":{"Duration":8203}}
@AnQueth I found a fix for the issue. The port was being used by Hyper-V and removing the exclusion was the solution. The below steps are from https://dev.to/trademark18/an-attempt-was-made-to-access-a-socket-4nh9.
- Open CMD as admin > enter netsh interface ipv4 show excludedportrange protocol=tcp
- Find the port range for 52323
- Enter the command - net stop winnat
- Enter the command - netsh int ipv4 add excludedportrange protocol=tcp startport=52323 numberofports=1
- Enter the command - net start winnat
- Attempt the port forward again
Frustrating issue as the netstat command didn't show the port being in use.