SQL Server shared LocalDB instance is not automatically starting

Cory Riddell 0 Reputation points
2024-10-01T15:33:46.8233333+00:00

I have an application that uses LocalDB. The named instance "PrivDb" is owned by whatever account installed the application. Part of the setup process is to grant "NT AUTHORITY\Authenticated Users" the sysadmin role so that any authenticated user can connect and the instance is shared as "SharedDb".

When another user on the machine tries to connect to the shared instance, it fails with this error:
User's image

If I manually start the instance as the user who installed it, other users on the machine can connect to the instance.

I'm running SQL Server Express 2022 with cumulative update 15 installed.

Is there something else that I have to configure so that the shared instance will automatically start when other users connect to it?


My problem seems identical to this one:
https://support.microsoft.com/en-us/topic/kb5003342-fix-sql-server-express-localdb-can-t-start-or-connect-to-shared-instances-of-sql-server-express-localdb-2019-or-2017-29147198-d431-47a4-80f0-ece917f28859

except I'm on the 2022 release.

SQL Server | Other
{count} votes

3 answers

Sort by: Most helpful
  1. ZoeHui-MSFT 41,536 Reputation points
    2024-10-02T06:42:06.2066667+00:00

    Hi @Cory Riddell,

    What about creating a batch file containing only the command starting SQL Server Express and schedule a task via Task Scheduler.

    https://dba.stackexchange.com/questions/52697/how-to-auto-start-instance-of-sql-server-2012-localdb-on-startup

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.


  2. Olaf Helper 47,581 Reputation points
    2024-10-02T06:57:15.7733333+00:00

    The server name "(LocalDB).\ShareDB" is wrong, exactly the addition slash+dot, remove "." =>

    "(LocalDB)\ShareDB"


  3. Cory Riddell 0 Reputation points
    2024-10-11T12:24:54.3866667+00:00

    I ended up writing a simple service to start the LocalDB instance. It creates a named pipe that clients can send a message over to start the instance.

    Unfortunately it doesn't work when running as SYSTEM. I'm calling LocalDBStartInstance and it returns S_OK, however the instance isn't actually started.

    If I modify the service to run as the user who owns the database, it works. This isn't a viable workaround though because it's too fragile. For example, if AD is configured to force users to change their password, the service will break because the stored password is now stale.

    When I use Process Monitor I can see my service starting SQLLocalDB and I can see it find the shared instance in the registry, find the owner and name of the instance, then it basically ends.

    Either I totally misunderstand shared instances and they are not intended to automatically start for other users on the machine, or it's a bug similar to the on in KB5003342. Is there any way to contact the developers who worked on that KB fix?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.