You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Az PowerShell模块时随机出现Socket地址占用错误求助

PowerShell 7.4.1 + Az模块随机出现套接字地址占用错误

环境信息

  • 使用官方Az PowerShell模块
  • PowerShell版本:7.4.1

错误详情

ErrorRecord                 : Only one usage of each socket address (protocol/network address/port) is normally permitted. (management.azure.com:443)
WasThrownFromThrowStatement : False
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
Message                     : The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Only one usage of each socket address (protocol/network address/port) is normally permitted. (management.azure.com:443)
Data                        : {[System.Management.Automation.Interpreter.InterpretedFrameInfo, System.Management.Automation.Interpreter.InterpretedFrameInfo[]]}
InnerException              :
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233087
StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                 at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)

触发错误的Cmdlet

以下Cmdlet执行时可能触发该错误,其他Cmdlet也可能受影响:

Get-AzRoleDefinition
Get-AzRoleAssignment
Get-AzSubscription
Get-AzManagementGroup

当前运行环境情况

  • 机器仅单用户登录,仅运行单个PowerShell实例
  • 脚本结束后会断开所有Azure会话,每次运行脚本时重新建立会话
  • 脚本运行状态不稳定,有时正常,有时在开头或结尾报错,甚至打开新PowerShell窗口也会出现错误
  • 对Azure的调用次数远低于100次,不足以耗尽本地可用端口

错误发生时的443端口连接状态

netstat -ano | findstr :443
  TCP    10.0.0.0:25203     13.107.213.45:443      ESTABLISHED     4332
  TCP    10.0.0.0:25218     20.190.190.100:443     ESTABLISHED     13392
  TCP    10.0.0.0:25221     92.123.151.23:443      ESTABLISHED     4332
  TCP    10.0.0.0:25227     51.116.150.70:443      TIME_WAIT       0
  TCP    10.0.0.0:25232     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:25234     51.116.150.70:443      ESTABLISHED     13392
  TCP    10.0.0.0:25237     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:25239     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:25240     13.107.246.45:443      CLOSE_WAIT      4332
  TCP    10.0.0.0:25249     204.79.197.239:443     ESTABLISHED     4332
  TCP    10.0.0.0:25250     20.42.73.28:443        ESTABLISHED     4332
  TCP    10.0.0.0:25254     51.116.150.70:443      TIME_WAIT       0
  TCP    10.0.0.0:25259     20.190.159.23:443      ESTABLISHED     4332
  TCP    10.0.0.0:25260     51.116.150.70:443      ESTABLISHED     13392
  TCP    10.0.0.0:25289     51.116.150.70:443      TIME_WAIT       0
  TCP    10.0.0.0:25290     34.252.119.145:443     ESTABLISHED     4332
  TCP    10.0.0.0:25293     20.190.190.100:443     ESTABLISHED     13392
  TCP    10.0.0.0:25294     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:25303     95.101.150.2:443       ESTABLISHED     4332
  TCP    10.0.0.0:25323     40.126.31.69:443       ESTABLISHED     13392
  TCP    10.0.0.0:25325     51.116.150.70:443      ESTABLISHED     13392
  TCP    10.0.0.0:25332     20.190.190.100:443     ESTABLISHED     13392
  TCP    10.0.0.0:25338     20.190.190.100:443     ESTABLISHED     13392
  TCP    10.0.0.0:25345     20.50.88.233:443       ESTABLISHED     13392
  TCP    10.0.0.0:25350     20.190.190.100:443     ESTABLISHED     13392
  TCP    10.0.0.0:25351     51.116.150.70:443      TIME_WAIT       0
  TCP    10.0.0.0:25356     20.42.73.28:443        ESTABLISHED     4332
  TCP    10.0.0.0:25360     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:25366     51.116.150.70:443      ESTABLISHED     13392
  TCP    10.0.0.0:25370     20.50.201.195:443      ESTABLISHED     4332
  TCP    10.0.0.0:25372     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:25376     40.126.31.69:443       TIME_WAIT       0
  TCP    10.0.0.0:25380     51.116.150.70:443      ESTABLISHED     13392
  TCP    10.0.0.0:25390     51.116.150.70:443      TIME_WAIT       0
  TCP    10.0.0.0:25393     51.116.156.32:443      TIME_WAIT       0
  TCP    10.0.0.0:49154     20.103.246.163:443     TIME_WAIT       0
  TCP    10.0.0.0:49156     52.178.17.234:443      TIME_WAIT       0
  TCP    10.0.0.0:49158     20.42.65.89:443        TIME_WAIT       0

补充说明

management.azure.com解析为51.116.150.70,该地址有10个开放连接,均属于当前PowerShell窗口进程(pwsh.exe,进程ID 13392),不存在其他进程冲突。


内容的提问来源于stack exchange,提问作者David Trevor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 03:12:04