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

Azure DevOps代理配置错误:目标机器主动拒绝连接

代理配置时出现“目标机器主动拒绝连接(10061)”的解决思路

你遇到的错误日志如下:

[2025-01-16 14:22:34Z INFO CommandSettings] Flag 'unattended': 'False'
[2025-01-16 14:22:34Z ERR  Terminal] WRITE ERROR (exception):
[2025-01-16 14:22:34Z ERR  Terminal] System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it.
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Services.Common.VssHttpRetryMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.Location.Client.LocationHttpClient.GetConnectionDataAsync(ConnectOptions connectOptions, Int64 lastChangeId, CancellationToken cancellationToken, Object userState)
   at Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.GetConnectionDataAsync(ConnectOptions connectOptions, Int32 lastChangeId, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.Location.VssServerDataProvider.ConnectAsync(ConnectOptions connectOptions, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.Agent.LocationServer.ConnectAsync(VssConnection jobConnection)
   at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.IsHostedServer(String serverUrl, VssCredentials credentials)
   at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.ConfigureAsync(CommandSettings command)
[2025-01-16 14:22:34Z ERR  Terminal] WRITE ERROR: Failed to connect.  Try again or ctrl-c to quit
[2025-01-16 14:22:34Z INFO CommandSettings] Arg 'url': ''
[2025-01-16 14:22:34Z INFO CommandSettings] Flag 'unattended': 'False'

结合你已经确认服务器正常、关闭代理机防火墙的情况,试试下面这些排查步骤:

  • 确认服务器URL输入是否正确:日志最后显示Arg 'url': '',说明配置时的服务器地址可能没被正确读取。检查输入的URL是否完整(比如带https://前缀、正确的端口),如果是命令行配置,注意是否有引号或者参数格式错误,比如是否漏了--url参数?
  • 测试代理机到服务器的网络连通性:用命令直接测试端口是否能通。Windows下用Test-NetConnection <服务器域名/IP> -Port <服务器端口>,Linux/macOS用nc -zv <服务器域名/IP> <服务器端口>。如果不通,说明中间网络(比如网关、路由器)有拦截规则,需要排查网络链路。
  • 清理旧代理的残留配置:这台机器之前做过代理,可能有旧配置残留。找到代理安装目录下的config文件夹(比如默认路径C:\agent\config或/home/user/agent/config),删除里面的.agent配置文件,再重新运行配置命令。
  • 检查PAT的有效性:确认你的Personal Access Token没过期,并且拥有**Agent Pools (Read & Manage)**权限。可以重新生成一个新的PAT,只保留必要的权限,再尝试配置。
  • 检查代理机是否有进程占用相关端口:如果之前的代理服务没完全停止,可能导致端口冲突。用netstat -ano | findstr <代理监听端口>(Windows)或lsof -i :<端口>(Linux/macOS)查看端口占用情况,结束对应的进程后再重新配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 01:16:02