SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist

11,544
  1. Make sure you have .NET Framework 4.0.2+ installed
  2. Set up your AppPool to run under the NetworkService account.
  3. Create a login for that account in your db.

    USE [master]; CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS; EXEC sp_addsrvrolemember N'NT AUTHORITY\NETWORK SERVICE', SYSADMIN;

  4. Share your instance with all users by running SqlLocalDB share Kentico KenticoShared

  5. Use connection string in the following format:

<add name="CMSConnectionString" connectionString="Data Source=(localdb)\.\KenticoShared;Initial Catalog=KenticoDB;Integrated Security=True;Connect Timeout=60" />

  1. If it doesn't help use a named pipe:

<add key="CMSConnectionString" value="Persist Security Info=False;Integrated Security=SSPI;database=KenticoDB;server=np:\\.\pipe\LOCALDB#D2BA6590\tsql\query;Current Language=English;Connection Timeout=120;" />

Notes:

  1. the exact name of the NetworkService account on your machine can be determined by running following C#

var ns = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null).Translate(typeof(NTAccount)).ToString()

  1. named pipe can be determined by running this in CMD: SqlLocalDB info KenticoShared
  2. don't forget to run your instance SqlLocalDB start KenticoShared
Share:
11,544

Related videos on Youtube

Jerreck
Author by

Jerreck

Programmer.

Updated on May 25, 2022

Comments

  • Jerreck
    Jerreck about 2 years

    EDIT: One important detail that I original left out (because I didn't know it was important) is that we were running these sites in full IIS, not from IIS Express.


    We're trying to setup local dev environments for Kentico CMS that will add our local machines to our current synchronization chain of Dev --> Staging --> Prod (so we'll wind up with Locals --> Dev --> Staging --> Prod).

    We copied our Dev DB to our local machines onto the (localdb)\v11.0 instance of SQL Server, but we're running into an issue on everyone's computers except mine.

    Here's the error we're getting:

    The application could not connect to the database, please check the connection string in the web.config file and SQL server availability.

    Original error:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. The specified LocalDB instance does not exist. )

    I've tried a ton of suggestions from other SO answers and other websites to figure out why we're getting this error (and why it's not happening on my machine), but no luck. We can connect to (localdb)\v11.0 in SSMS but we cannot connect to it through VS (same error). Also, when we open Sql Server Config Manager, we're not seeing any listings for SQL Server Services. Any ideas?

    • Chris
      Chris over 9 years
      Can you verify that localDb is installed on your machine? What happens if you open SSMS and try to connect to (localdb)\v11.0 ?
    • Jerreck
      Jerreck over 9 years
      We can connect to (localdb)\v11.0 through SSMS just fine, but we cannot add (localdb)\v11.0 as a connection in VS. I thought that was really weird since I was under the assumption that (localdb)\v11.0 was the instance that VS 2013 creates and uses by default.
    • Chris
      Chris over 9 years
      Have you looked into this? Connect LocalDb in VS server explorer
    • Jerreck
      Jerreck over 9 years
      Just talked to one of my developers, and apparently he did everything listed there except using the instance pipe name. He could connect to (localdb)\v11.0 from VS but his instance of Kentico was still getting the SQL Network Interfaces, error: 50. Can you use the instance pipe name as a connection string in the web config? We're going to put off testing this for a couple days because we found a work around and we're on a tight schedule, but we'll come back to it soon.
  • jr-juxtaposition
    jr-juxtaposition almost 7 years
    Thanks for this. For me what got the connection working was finding and using the named pipe. Both IIS Express and my IIS app pool run as the same user. Very mysterious why i could connect from one but not the other.
  • jr-juxtaposition
    jr-juxtaposition almost 7 years
    In hopes that this might come up in more search results, i'll also mention that besides the IIS weirdness, i also had this same issue on a connection from a Windows Service that was using SQL Server authentication, and the connection would mysteriously work or not work depending on what Windows user the service was configured to run as.