SQL: Avoiding connection timeouts on first connection to LocalDB edition of SQL Server Express

SQL: Avoiding connection timeouts on first connection to LocalDB edition of SQL Server Express

When you first make a connection to the new LocalDB edition of SQL Server Express, the system files, etc. that are required for a new version are spun up. (The system files such as the master database files, etc. end up in:

C:\\Users\\<username>\\AppData\\Local\\Microsoft\\Microsoft SQL Server Local DB\\Instances\\LocalDBApp1) 

Now that can take a while on a slower machine, so this means that the default connection timeout of 30 seconds that you’ll find in most client libraries, could well be exceeded.

Now you could increase the Connect Timeout value in your connection string, but you might not want to change that.

But there is another option to avoid this hit on the first connection. You can pre-create the required instance of LocalDB beforehand using the SqlLocalDB.exe utility, like this:

<path to binaries>\\SqlLocalDB.exe create InstanceName

You can also specify the required version of SQL Server and ask to start the instance like this:

<path to binaries>\\SqlLocalDB.exe create InstanceName 17.0 -s

Your application should then connect quickly, even on the first connection.

2026-02-23