error: 40 - Could not open a connection to SQL Server

K. MOHANA PRIYA 41 Reputation points

I am getting an Exception Unhandled error.

System.Data.SqlClient.SqlException: '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)'

Inner Exception
Win32Exception: The network path was not found.

It show that check the server allow to remote connection and the instance. I checked the connection and also the instance all are correct.
Anyone tell me how to solve it.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
8,490 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Uri Dimant 206 Reputation points
    1. Make sure SQL Server Service is running
    2. If a named instance, make sure SQL Server browser service is running
    3. Make sure SQL Server is configured to allow remote connections
    4. Examine the SQL Server error log for messages confirming that SQL is listening on the expected network interfaces and ports
    5. Test server connectivity with PING from the client machine
    6. Test port connectivity using TELNET or PowerShell to the server and port (from step 4) from the client machine. For example
      a. TELNET <server-name> 1433
      b. PowerShell: 1433 | % { echo ((new-object Net.Sockets.TcpClient).Connect("YourServerName",$)) "server listening on TCP port $" }
    7. Check firewall settings if step 5 or 6 connectivity test fails

  2. NOBTA 86 Reputation points

    You may check whether TCP/Named pipes setting is enabled on SQL Server if you use SQL Server Developer Edition. The default setting of TCP/Named pipes is disable on SQL Server Developer Edition. You can change this setting using SQL Server configuration manager. And also you may check firewall configured for incoming connections on Windows OS.

    No comments