The network path was not found


I'm running my code and getting this error. But what does it mean?

The network path was not found Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The network path was not found

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Win32Exception (0x80004005): The network path was not found]

[SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]

asked on Stack Overflow Jan 30, 2014 by user3278908 • edited Jan 30, 2014 by Kad

8 Answers


This is probably related to your database connection string or something like that.

I just solved this exception right now. What was happening is that I was using a connection string intended to be used when debugging in a different machine (the server).

I commented the wrong connection string in Web.config and uncommented the right one. Now I'm back in business... this is something I forget to look at after sometime not working in a given solution. ;)

answered on Stack Overflow Oct 17, 2014 by Leniel Maccaferri

You will also get this exact error if attempting to access your remote/prod db from localhost and you've forgotten that this particular hosting company requires VPN logon in order to access the db (do i feel silly).

answered on Stack Overflow Apr 25, 2018 by puddleglum • edited Apr 25, 2018 by puddleglum

There may be some reasons like:

  1. Wrong SQL connection string.
  2. SQL Server in services is not running.
  3. Distributed Transaction Coordinator service is not running.

First try to connect from SQL Server Management Studio to your Remote database. If it connects it means problem is at the code side or at Visual Studio side if you are using the one.

Check the connectionstring, if the problem persists, check these two services:

  1. Distributed Transaction Coordinator service
  2. SQL Server services.

Go in services.msc and search and start these two services.

The above answer works for the Exception: [Win32Exception (0x80004005): The network path was not found]

answered on Stack Overflow Oct 23, 2016 by Kshitij Jhangra

Same problem with me. I solved this by adding @ before connection string (C# has a thing called 'String Literals') like so:

SqlConnection sconnection = new SqlConnection(@"Data Source=(Localdb)\v11.0; Initial Catalog=Mydatabase;Integrated Security=True");

answered on Stack Overflow Mar 4, 2016 by (unknown user) • edited Nov 26, 2016 by Ivan Rubinson

As others pointed out this could be more to do with the connectionstring config Make sure,

  1. user id and password are correct
  2. Data Source is pointing to correct one , for example if you are using SQL express it will be .\SQLEXPRESS
  3. Database is pointing to correct name of database Hope that helps.
answered on Stack Overflow Dec 22, 2016 by Nathan Senevirathne

Possibly also check the sessionState tag in Web.config

Believe it or not, some projects I've worked on will set a connection string here as well.

Setting this config to:

<sessionState mode="InProc" />

Fixed this issue in my case after checking all other connection strings were correct.

answered on Stack Overflow Jan 18, 2017 by ooXei1sh

I recently had the same issue. It's more likely that your application can not connect to database server due to the network issues.

In my case I was connected to wrong WiFi.

answered on Stack Overflow Dec 15, 2017 by Komal Narang

check your Connection String Properly. Check that the connection is open.

String CS=ConfigurationManager.COnnectionStrings["DBCS"].connectionString;
    {enter code here
   SqlConnection con = new SqlConnection(CS);
    SqlCommand cmd = new SqlCommand("select * from tblCountry", con);
     SqlDataAdapter da = new SqlDataAdapter(cmd);
     DataTable dt = new DataTable();
//Bind data
answered on Stack Overflow Apr 30, 2019 by Priyank Raunak • edited Apr 30, 2019 by Robert

User contributions licensed under CC BY-SA 3.0