TFS Build agent running but still displayed as offline

A colleague of mine notified me today that there was a problem with the TFS build agent on our TFS server. When he tried to queue a build, the following message popped up:

There are issues with the request or definition that may prevent the build from running:
There are agents that are capable of running the build, but they are not online. If the agent is configured to run as a service, ensure that the “VSO Agent ({agent name})” service is running.


This looked like a no-brainer. Probably the service which was not started. When I looked at the service, I noticed that it was running.


I checked the Agent pools in the TFS Control Panel and this was showing a red status while it should be green. Not good.


To see what was going on, I went to the folder where the agent was installed. In that folder, a _diag folder exists with logging. After opening one of the log files, I noticed this error:

System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.WebException: Unable to connect to the remote server —> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

(IP is replaced with xxx in the message above).

The IP which was listed, was the IP of the TFS server. What got me thinking in the right direction for a solution, is a part of the logfile above the message where the settings are loaded:

VsoAgent.exe was run with the following command line: “C:\BuildAgent\agent\vsoagent.exe” /runningAsService
12:04:06.109768 SettingsFileHelper.Load – settings[AutoUpdate]=True
12:04:06.109768 SettingsFileHelper.Load – settings[RootFolder]=C:\BuildAgent
12:04:06.109768 SettingsFileHelper.Load – settings[WorkFolder]=c:\BuildAgent\_work
12:04:06.109768 SettingsFileHelper.Load – settings[ServerUrl]=
12:04:06.109768 SettingsFileHelper.Load – settings[AgentName]=xxxxx
12:04:06.109768 SettingsFileHelper.Load – settings[PoolId]=1
12:04:06.109768 SettingsFileHelper.Load – settings[PoolName]=default
12:04:06.109768 SettingsFileHelper.Load – settings[AgentId]=2
12:04:06.109768 SettingsFileHelper.Load – settings[RunAsWindowsService]=True
12:04:06.109768 SettingsFileHelper.Load – settings[WindowsServiceName]=vsoagent.tfs.xxxxx
12:04:06.109768 SettingsFileHelper.Load – settings[WindowsServiceDisplayName]=VSO Agent (xxxxx)

The “ServerUrl” setting listed the default URL for TFS. Which is HTTP on port 8080. But I remembered that we changed our configuration to run on HTTPS. So, our TFS was not at 8080, but 443 and then it hit me… I configured the buildagent before we changed to HTTPS.

The solution to this issue was pretty clear, I needed to update the “settings.json” file in the buildagent folder and replace the old URL with the new one.
After changing this file, I restarted the buildagent service, went back to the Agent Pools, refreshed the page and noticed the status changed to green.


Good to go!