Error while detaching the Collection database : TF246017: Team Foundation Server could not connect to the database.

Environment: TFS 2017

Last weekend while I was with a customer I observed the below error message, it’s interesting to know that this error happened while we were detaching the database to take back up and we could never attach it back again.

TF246017: Team Foundation Server could not connect to the database. Verify that the instance is specified correctly, that the server that is hosting the database is operational, and that network problems are not blocking communication with the server.

When we rerun the job, it failed without a clue. Looking at various parameters and logs were landing at the above error.

On the go, we found the TfsWarehouse database (from the old 2008 days) was in recovery state. While detaching the database the scripts looked for it and it was not reachable, hence the error message.
The TfsWarehouse database was fixed from recovery state, then the detach and attach worked seamlessly. So it is a good idea to see what’s the state of databases in the SQL instance.

Content: Vimal Thiagaraj