The Server Does Not Start Claiming the Database is in Use
Only a single TeamCity server can work with one database, which is checked on the TeamCity server start.
"The Database is in Use" error on the start-up is reported in either of the following cases:
- An attempt to start more than one TeamCity server connected to the same database
- A second TeamCity instance detected
- The internal HSQL database is being used by another application
The error is most probably caused by the fact that there is another running TeamCity installation which is connected to the same database. Сheck that the database properties are correct and there is no other TeamCity server using the same database.
In TeamCity 8.0 and earlier, if all the settings are correct, the error can occur when the TeamCity server or the database server has been shut down incorrectly.
The resolution depends on the database type:
- MySQL: restart the MySQL server and then start TeamCity again.
- PostgreSQL, Oracle, MS SQL: kill the connections from the incorrectly shut down TeamCity, and then start TeamCity again.
- Internal database (HSQL): remove the buildserver.lck file from the TeamCity Data Directory\system directory, and then start TeamCity again.
Please sign in to leave a comment.
This is happening on a system Restart, and only on a Restart. Manually starting the server works. So, it seems to me, in my naivete, that none of the three bulletin points apply to my case. I mean, I understand that “A second TeamCity instance detected”. Why? My system just restarted. I'm trying to start just one instance. I use a .cmd file, which calls a .ps1 file, which cd's to the directory and runs .\teamcity-server.bat start
I'm not doing anything fancy. I've double and triple-checked, the version I'm running is Version: 2024.12 - the latest version - not version 8.0 or earlier.
I'm using the internal HSQL database, although eventually we'll use MS SQL.
[Edit 2025-02-12] I have edited the startup script to one line. All it says is:
PowerShell c:\TeamCity\bin\teamcity-server.bat start
And I still get the “A second TeamCity instance detected”.
Reproduction steps:
Any suggestions?