Network related or instance specific error occurred while establishing a connection to sql server

I get the following error when trying to connect to SQL Server: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was...

When I experienced this error in Visual Studio,

“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)”

…it was during the execution of the following C# code, which was attempting to obtain my SQL Server data to display it in a grid. The break occurred exactly on the line that says connect.Open():

        using (var connect = Connections.mySqlConnection)
        {
            const string query = "SELECT Name, Birthdate, Narrative FROM Friends";
            using (var command = new SqlCommand(query, connect))
            {
                connect.Open();
                using (var dr = command.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        // blah
                    }
                }
            }
        }

It was inexplicable because the SQL query was very simple, I had the right connection string, and the database server was available. I decided to run the actual SQL query manually myself in SQL Management Studio and it ran just fine and yielded several records. But one thing stood out in the query results: there was some improperly encoded HTML text inside a varchar(max) type field within the Friends table (specifically, some encoded comment symbols of the sort <!-- lodged within the «Narrative» column’s data). The suspect data row looked like this:

Name    Birthdate    Narrative
====    =========    ============== 
Fred    21-Oct-79    &lt;!--HTML Comment -->Once upon a time...

Notice the encoded HTML symbol «&lt;«, which stood for a «<» character. Somehow that made its way into the database and my C# code could not pick it up! It failed everytime right at the connect.Open() line! After I manually edited that one row of data in the database table Friends and put in the decoded «<» character instead, everything worked! Here’s what that row should have looked like:

Name    Birthdate    Narrative
====    =========    ============== 
Fred    21-Oct-79    <!--HTML Comment -->Once upon a time...

I edited the one bad row I had by using this simple UPDATE statement below. But if you had several offending rows of encoded HTML, you might need a more elaborate UPDATE statement that uses the REPLACE function:

UPDATE Friends SET Narrative = '<!--HTML Comment -->Once upon a time...' WHERE Narrative LIKE '&lt%'

So, the moral of the story is (at least in my case), sanitize your HTML content before storing it in the database and you won’t get this cryptic SQL Server error in the first place! (Uh, properly sanitizing/decoding your HTML content is the subject of another discussion worthy of a separate StackOverflow search if you need more information!)

When I experienced this error in Visual Studio,

“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)”

…it was during the execution of the following C# code, which was attempting to obtain my SQL Server data to display it in a grid. The break occurred exactly on the line that says connect.Open():

        using (var connect = Connections.mySqlConnection)
        {
            const string query = "SELECT Name, Birthdate, Narrative FROM Friends";
            using (var command = new SqlCommand(query, connect))
            {
                connect.Open();
                using (var dr = command.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        // blah
                    }
                }
            }
        }

It was inexplicable because the SQL query was very simple, I had the right connection string, and the database server was available. I decided to run the actual SQL query manually myself in SQL Management Studio and it ran just fine and yielded several records. But one thing stood out in the query results: there was some improperly encoded HTML text inside a varchar(max) type field within the Friends table (specifically, some encoded comment symbols of the sort <!-- lodged within the «Narrative» column’s data). The suspect data row looked like this:

Name    Birthdate    Narrative
====    =========    ============== 
Fred    21-Oct-79    &lt;!--HTML Comment -->Once upon a time...

Notice the encoded HTML symbol «&lt;«, which stood for a «<» character. Somehow that made its way into the database and my C# code could not pick it up! It failed everytime right at the connect.Open() line! After I manually edited that one row of data in the database table Friends and put in the decoded «<» character instead, everything worked! Here’s what that row should have looked like:

Name    Birthdate    Narrative
====    =========    ============== 
Fred    21-Oct-79    <!--HTML Comment -->Once upon a time...

I edited the one bad row I had by using this simple UPDATE statement below. But if you had several offending rows of encoded HTML, you might need a more elaborate UPDATE statement that uses the REPLACE function:

UPDATE Friends SET Narrative = '<!--HTML Comment -->Once upon a time...' WHERE Narrative LIKE '&lt%'

So, the moral of the story is (at least in my case), sanitize your HTML content before storing it in the database and you won’t get this cryptic SQL Server error in the first place! (Uh, properly sanitizing/decoding your HTML content is the subject of another discussion worthy of a separate StackOverflow search if you need more information!)

In this article, we will be discussing about a popular error message, that is: “A network-related or instance-specific error occurred while establishing a connection to SQL Server

Under certain circumstances, there are cases where you might try to connect to a SQL Server instance and get the error message: “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: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

A network-related or instance-specific error occurred while establishing a connection to SQL Server

This is the standard error message you get when your client does not “see” the SQL Server instance you are trying to connect to. However, there is more than one possible reasons for getting this message.

Possible Reasons for the network-related or instance-specific error

Here’s a list of possible reasons:

  • [Reason 1] You may have misspelled the instance name or IP 🙂
    • How to further investigate: 
      From the client, try to ping the network name for the SQL Server instance and see if you get a response.

      • If it is a default instance (i.e. SQLInstance1.contoso.local) then ping “SQLInstance1.contoso.local”
      • If it is a named instance  (i.e. VirtualName1.contoso.localSQLInstance1) then ping “VirtualName1.contoso.local”
        > If ping does not reply, make sure that you are using the correct network name.
        > If you still cannot connect to SQL Server, proceed and check the rest of possible reasons.
  • [Reason 2] If the SQL Server instance is located on a different domain than your client, you may have not included the fully qualified domain name (FQDN) in the SQL Server instance name (i.e. SQLInstance1 vs SQLInstance1.contoso.local) – this assumes that the two domains are trusted between them
    • How to further investigate:
      Again, just like the actions in possible reason 1, try to ping the instance name from the client using the instance’s FQDN.
      > If you still cannot connect to SQL Server, proceed and check the rest of possible reasons.
  • [Reason 3] If there is a firewall in your network, you might not be allowed to access the SQL Server instance through the network.
    • How to further investigate:
      If you know for example that you want to connect to the SQL Server instance “SQLInstance1.contoso.local” on port 52500, then you can try from a command prompt on the client, to run the command: telnet SQLInstance1.contoso.local 52500
      If the above telnet command reports that “Could not open connection to the host, on port 52500: Connect failed” (or something similar), it means that there is no network communication between the client and the SQL Server instance at the designated port number. In this case, you should report it to your Network administrator.
  • [Reason 4] If you are trying to connect to a named instance, make sure that the SQL Server Browser service is running.
    • How to further investigate:
      Remotely connect on the SQL Server machine (or via remote administration) and check that the “SQL Server Browser” service is up and running.
  • [Reason 5] Make sure that your SQL Server instance allows remote connections.
    • How to further investigate:
      Connect remotely on the SQL Server machine, and log in to SQL Server Database Engine via SQL Server Management Studio. Then, right-click on the instance name, select “Properties” and check the “Connections” tab to see if the SQL Server instance allows remote connections. See the below screenshot for example.

      A network-related or instance-specific error occurred while establishing a connection to SQL Server

Hopefully if you go through the above, you will finally manage to successfully connect to your SQL Server instance.

Strengthen your SQL Server Administration Skills – Enroll to our Online Course!

Check our online course on Udemy titled “Essential SQL Server Administration Tips(special limited-time discount included in link).

Via the course, you will learn essential hands-on SQL Server Administration tips on SQL Server maintenance, security, performance, integration, error handling and more. Many live demonstrations and downloadable resources included!

Essential SQL Server Administration Tips - Online Course with Live Demonstrations and Hands-on Guides

(Lifetime Access/ Live Demos / Downloadable Resources and more!)

Enroll from $14.99

Featured Online Courses:

  • Boost SQL Server Database Performance with In-Memory OLTP 
  • Essential SQL Server Administration Tips
  • SQL Server Fundamentals – SQL Database for Beginners
  • Essential SQL Server Development Tips for SQL Developers
  • The Philosophy and Fundamentals of Computer Programming
  • .NET Programming for Beginners – Windows Forms with C#
  • Introduction to SQL Server Machine Learning Services
  • Introduction to Azure SQL Database for Beginners
  • SQL Server 2019: What’s New – New and Enhanced Features
  • Entity Framework: Getting Started – Complete Beginners Guide
  • How to Import and Export Data in SQL Server Databases
  • Learn How to Install and Start Using SQL Server in 30 Mins
  • A Guide on How to Start and Monetize a Successful Blog

Related Error Messages and ways to Resolve them:

  • Operating System Error 170 (Requested Resource is in use)
  • There is no SQL Server Failover Cluster Available to Join
  • Setup failed to start on the remote machine. Check the Task scheduler event log on the remote machine.
  • SQL Server 2008 R2 Service Pack Installation Fails – Element not found. (Exception from HRESULT: 0x80070490)
  • Could not load file or assembly ‘Microsoft.SqlServer.Smo, Version=10.0.0.0, …
  • The operation failed because either the specified cluster node is not the owner of the group, or the node is not a possible owner of the group
  • There is not enough space on the disk. (mscorlib)
  • The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value
  • … more SQL Server troubleshooting articles

Check out our latest software releases!

Subscribe to our newsletter and stay up to date!

Easily generate snippets with Snippets Generator!

Secure your databases using DBA Security Advisor!

Convert static T-SQL to dynamic and vice versa with Dynamic SQL Generator.

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)

Loading…

Reference: SQLNetHub.com (https://www.sqlnethub.com)

© 2018 SQLNetHub

Artemakis Artemiou

Artemakis Artemiou is a Senior SQL Server Architect, Author, a 9 Times Microsoft Data Platform MVP (2009-2018). He has over 20 years of experience in the IT industry in various roles. Artemakis is the founder of SQLNetHub and {essentialDevTips.com}. Artemakis is the creator of the well-known software tools Snippets Generator and DBA Security Advisor. Also, he is the author of many eBooks on SQL Server. Artemakis currently serves as the President of the Cyprus .NET User Group (CDNUG) and the International .NET Association Country Leader for Cyprus (INETA). Moreover, Artemakis teaches on Udemy, you can check his courses here.

Views: 5,744

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit «Cookie Settings» to provide a controlled consent. Read More

“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) (Microsoft SQL Server, Error: 53)”.

A network-related or instance-specific error occurred while establishing a connection to SQL Server.

The article discusses a thorough list of troubleshooting methods that can be used to connect to the SQL server. First of all, we will discuss problems that arise when you need to connect to the remote server using IP address as this is the most common cause. These steps are written in “SQL Server 2008 R2″ on “Windows 10″, but they can be used on other versions too with minor amendments.

The error usually means that the “SQL server is not found” or “TCP port is either unknown or wrong”, or it can be blocked by the “firewall”.

Method 1: Gather information about the instance of the SQL Server.

In this section, we will discuss ways to check either the instance of the SQL Server is working or not, along with methods to fix it if it is not working.

Step 1. Check if an instance of SQL Server is installed and is working or not

First of all login to the computer hosting the SQL server instance.  Now, follow these steps to open Services in Windows.

  1. Click on the “Start menu” and then point to “All programs”.
  2. Now point to the SQL Server, and then point to “Configuration tools”
  3. Click “SQL Server Configuration Manager”.
  4. Now select “SQL Server services” and check in the right pane whether the instance of a database engine is running or not.
  5. Moreover, this can be opened directly by typing “services.msc” in the RUN and click OK. The following screen appears.

Opening services by typing “services.msc” in the RUN box.

Now, check if the database engine has been configured to accept remote connections. To check this, follow the following steps.

  1.  After services have been opened you can see database engine in the right pane. The “MSSQLSERVER” is a default unnamed instance. A default instance can only be one.
  2. In the case of the “SQL Express”, default instance will be “SQLEXPRESS” unless it is renamed by someone during installation.
  3. Check if the instance you are trying to connect has the same name as given in the services.
  4. Also, confirm if the status of the instance is “RUNNING”.
  5. Moreover, if you are trying to connect to named instant, then double-check if “SQL Server Browser service” is already running. Thus you need to check if the “SQL Server Browser service” is started on the server on which SQL Server is installed.
  6. In case, the database engine is not running then you need to restart it. So to start the “Database Engine”, in the right pane, right-click on the “Database Engine” (“MSSQLSERVER” default one), and then click “Start”.

Check if the “SQL Server Browser service” is already running.

Step 2. Obtain the IP address of the computer.

To do this follow these steps.

  1. First of all, from the start menu, click “RUN” and type “cmd” and press ok.
  2. In command prompt window type “ipconfig” and note down IPV4 and IPV6 addresses. People mostly use IPV4 address.

Get IPv4 address

Step 3. Get the TCP port number used by the SQL server

Follow the following steps to get TCP port number used by the SQL server

  1. Using “SQL Server Management Studio” (SSMS) connect to the instance of SQL server
  2. From “object explorer” expand “Management”, expand “SQL server log” and click on the current log on which you have to apply filter.
  3. To apply filer click apply filter and type ” server is listening on” in Message contains text box. Click apply filter and press ok.
    Applying filter ” server is listening on”
  4. A message like “server is listening on [‘any’ <ipv4> 1433]” should be shown. The message shows that the SQL Server instance is listening on all computers with IP address IPv4 and TCP port is 1433 (default).
  5. For more than one instance TCP port will be different for each instance.
    Message showing server is listening on IPv4 and port 1433
  6. If it is not a case then click “All programs”, point to MS SQL server configuration tools, “SQL server configuration management” , and right-click “TCPIP” and click enable and restart SQL server to let changes create impact.

Method 2: Enabling protocols for port 1433

Connecting to the “Database Engine” from another computer is not allowed in many “SQL Server” implementations unless an administrator utilizes “Configuration Manager” to allow it. The following steps should be followed to do this.

  1. Click on “Start menu” and then point to “All programs”
  2. Point towards the “SQL Server 2008 R2”
  3. Point towards “Configuration tools”, and after this click “SQL Server Configuration Manager”.
  4. Expand “SQL Server Network Configuration”.
  5. Select “protocols for MSSQL server”. Click on “TCPIP” in the right panel.
    Opening “Protocol Tab”
  6. In the tab “protocol” set enable as “yes”.
  7. Choose the “IP Address tab” from the window and set “TCP Port” equal to “1433″ in the “IP All” entry.
    Set port no in “IP Address tab”
  8. Now restart database engine to make changes leave their impact. To do this from the left pane, select SQL server services and then from right pane right-click database engine instance and press “restart”.

Method 3: Create a Firewall exception

Sometimes Windows firewall turns on and blocks links from another computer. To fix it follow these steps.

  1. Click “Start” and start typing “Firewall.cpl” in the run box.
    Opening “Firewall.cpl”
  2. You get the “configuration frame” for Windows Firewall by running the “firewall.cpl” command. You may turn the firewall “on/off” with exceptions and other settings applied here. Check the firewall status and turn it on to activate it if the firewall is off. If you’ve just turned this on, your firewall will block any “SQL Server” connection request to your computer at this point. Through making certain exceptions, you’d need to configure the firewall to allow access to a SQL Server database engine.
  3. Click on “Advanced Settings”
    Click on advanced settings option to open firewall rules
  4. We need to learn about the ports used for “SQL Server” and the “SQL Server Browser” feature when dealing with “SQL Server” firewall configurations. Both are involved in setting up a “firewall” for the “SQL Server” . It would, therefore, be necessary to go separately through both concepts.
  5. You may permit or block traffic attempts that meet the requirements in the rule to access the computer. By default  “inbound traffic” is blocked, you need to establish “inbound rule” to allow traffic to reach the computer. Tap the Inbound Rules from the left pane of the “Windows Firewall with Advanced Security” and click the New Rule from the “Actions” window. 
    Selecting New Rule from the “Actions” window.
  6. Select “Portunder “Rule Typeand pressNext” button
    Selecting “port” option
  7. Now select “Specific local ports” and set it to 1433
    set “specific local port” to 1433
  8. Now select “Allow the connection” in the “Action” dialog and press the Next button
    selecting “Allow the connection”
  9. Give the rule atitle” on this stage and press the “Finish” button.
    Give a title to the rule
  10. Select “Custom rule” from “New rule” tab
    Select “Custom rule” from “New rule” tab
  11. Click “customize”
    Click “customize”
  12. Select “Database Engine Instance Service” from the “Customize Service Settings” under “Apply to this service” and click the “OK” button
    Select “Database Engine Instance Service” from the “Customize Service Settings” under “Apply to this service” and click the “OK” button
  13. Give the rule a name and click finish
    Give a title to the new rule
  14. Also add “sqlservr.exe” typically located in “C:Program Files (x86)Microsoft SQL ServerMSSQL.xMSSQLBin” (or check your actual folder path) to the path, check your installs for the actual folder path) and port whose default value is “1433”. Also, check your connection string.

Method 4: Check Local connection

One of the reasons for this error is if we provide the wrong server name, this will result in an error. As seen in the figure below provided server name is “DESKTOP-UD88TLT1” whereas accurate server name is “DESKTOP-UD88TLT”. So it will be unable to connect to the server which will result in an error “cannot connect to server”. This is the most basic reason for error, so we should check it first if working locally.

The error arises while locally connecting to SQL server with the wrong server name In case you are using express edition following your server name, add “SQLEXPRESS” as seen in the figure below.

Locally connecting to SQL server while using express edition

Photo of Sadia Majeed

Sadia Majeed

Sadia is an Enthusiastic and experienced professional with technical expertise in multiple tools and technologies including database, data ware housing, business intelligence and data science.

  • Remove From My Forums
  • Question

  • I’ve just installed sql server 2008 r2 and i restored my DB, and i receive this error:

    I have got the above 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: Named Pipes Provider, error: 40 — Could not open a connection to SQL Server)ExecuteNonQuery requires an open and available Connection. The connection’s current state
    is closed.

    Please Help Me.

    Thanks,

    Harish

    • Edited by

      Thursday, December 13, 2012 1:52 PM

Answers

  • If you are running Visual Studio on your local machine, we can forget all about firewalls and enabling of TCP/IP. That matters when you connect from a different machine.

    So let’s focus on how you connect from Visual Studio? Can you include a screenshot.

    There is some puzzling information in your post. I assume that your machine name is CEO-PC and not CEO-PC/SQLSERVER? When you connect to a named instance, you should use a backslash () as the separator, not a forward slash. Furthermore,
    the default name for an instance of Express Edition is SQLEXPRESS, and this is confirmed by your output from SQL Server Configuration Manager.

    If you are attempting to connect from Visual Studio with CEO-PC/SQLSERVER, try CEO-PCSQLEXPRESS.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    • Marked as answer by
      Allen Li — MSFT
      Wednesday, December 19, 2012 1:41 AM

  • I am connecting with DATA SOURCE as CEO-PC/SQLEXPRESS. This is my connection string.

    Data Source=CEO-PC/SQLEXPRESS;Initial Catalog=Test;Integrated Security=True;

    Tilt the slash.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    • Marked as answer by
      Allen Li — MSFT
      Wednesday, December 19, 2012 1:41 AM

Содержание

  1. KB3174829 — FIX: «A network-related or instance-specific error occurred» when you repair SQL Server 2016
  2. Symptoms
  3. Resolution
  4. A network-related or instance-specific error occurred while establishing a connection to SQL Server
  5. Error messages
  6. «A network-related or instance-specific error occurred while establishing a connection to SQL Server. Verify that the instance name is correct and that SQL Server is configured to allow remote connections»
  7. «SQL Server does not exist or access denied»
  8. Gather information for troubleshooting the error
  9. Option 1: Use the SQL Check tool to gather the required information
  10. Option 2: Collect the data individually using the following procedures
  11. Get the instance name from Configuration Manager
  12. Get the IP address of the server
  13. Get the TCP port of the instance
  14. Step 1пјљVerify that the instance is running
  15. Option 1: Using the output file from the SQLCheck tool
  16. Option 2: Use SQL Server Configuration Manager
  17. Option 3: Use PowerShell commands
  18. Step 2: Verify that the SQL Server Browser service is running
  19. Option 1: Using the output file from SQLCheck tool
  20. Option 2: Use SQL Server Configuration Manager
  21. Step 3: Verify the server name in the connection string
  22. Step 4: Verify the aliases on the client machines
  23. Option 1: Using the output file from the SQLCheck tool
  24. Option 2: Check aliases in SQL Server Configuration Manager
  25. Option 3: Check aliases in SQL Server Client Network Utility
  26. Step 5: Verify the firewall configuration
  27. Default instance of SQL Server
  28. Named instance of SQL Server
  29. Step 6: Verify the enabled protocols on SQL Server
  30. Option 1: Using the output file from SQLCheck tool
  31. Option 2: Use SQL Server Configuration Manager
  32. Step 7: Test TCP/IP connectivity
  33. Step 8: Test local connection
  34. Step 9: Test remote connection

Symptoms

When you repair a SQL Server 2016 installation in the following scenarios:

You sign on to Windows as a user who is not a member of SQL Server Administrators.

The SQL Server service is stopped.

In either of the preceding scenarios, during the repair progress SQL_Telemetry_LoginRepair_Startup_Cpu64, you may receive an error message in a pop-up window that resembles the following:

Microsoft SQL Server 2016 Setup
The following error has occurred:
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) Click ‘Retry’ to retry the failed action, or click ‘Cancel’ to cancel this action and continue setup.

Note If you click Cancel to close the pop-up window, the repair can still finish successfully.

Resolution

The issue was first fixed in the following cumulative update of SQL Server:

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. We recommend that you download and install the latest cumulative updates for SQL Server:

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the «Applies to» section.

Learn about the terminology that Microsoft uses to describe software updates.

Источник

Applies to: В SQL Server

When connecting to a SQL Server instance, you may encounter one or more of the error messages below. This article provides some steps to help you troubleshoot these errors, which are provided in order of the issues from simple to complex.

Error messages

The complete error messages vary depending on the client library that is used in the application and the server environment. You can check the following details to see if you’re encountering one of the following error messages:

provider: Named Pipes Provider, error: 40 — Could not open a connection to SQL Server (Microsoft SQL Server, Error: 53) 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 (Microsoft SQL Server, Error: 53)
provider: TCP Provider, error: 0 — No such host is known. (Microsoft SQL Server, Error: 11001)

provider: SQL Network Interfaces, error: 26 — Error Locating Server/Instance Specified 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: 26 — Error Locating Server/Instance Specified

Login timeout expired SQL Server Native Client Data Link Error
[Microsoft SQL Server Native Client 10.0]: Login timeout expired
[Microsoft SQL Server Native Client 10.0]: A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
[Microsoft SQL Server Native Client 10.0]: SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF].

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 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: TCP Provider, error: 0
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Microsoft SQL Server, Error: 10060

provider: Named Pipes Provider, error: 40 — Could not open a connection to SQL Server 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
Microsoft SQL Server, Error: 53
The network path was not found

[Microsoft][SQL Server Native Client 11.0]TCP Provider: No connection could be made because the target machine actively refused it SQL Server Native Client Data Link Error
[Microsoft][SQL Server Native Client 11.0]TCP Provider: No connection could be made because the target machine actively refused it.
[Microsoft][SQL Server Native Client 11.0]Login timeout expired.
[Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.

«SQL Server does not exist or access denied»

This error usually means that the client can’t find the SQL Server instance. This issue occurs when at least one of the following problems exists:

  • The name of the computer hosting SQL Server is incorrect.
  • The instance doesn’t resolve the correct IP.
  • The TCP port number isn’t specified correctly.

For troubleshooting connectivity issues in high availability scenarios, see the following articles:

Gather information for troubleshooting the error

We recommend that you gather the information listed in this section using one of the options below before proceeding with the actual steps to troubleshoot the error.

Option 1: Use the SQL Check tool to gather the required information

If you can sign in locally to the SQL Server computer and have administrator access, use SQLCheck from the Microsoft SQL Networking GitHub repository. This tool provides most of the information required for troubleshooting in one file. Review the tool’s home page for more information on using the tool and the information it gathers. You can also check the recommended prerequisites and checklist page.

Option 2: Collect the data individually using the following procedures

Get the instance name from Configuration Manager

On the server that hosts the SQL Server instance, use SQL Server Configuration Manager to verify the instance name:

Configuration Manager is automatically installed on the computer when SQL Server is installed. Instructions on starting Configuration Manager vary slightly by versions of SQL Server and Windows. For version-specific details, see SQL Server Configuration Manager.

Sign in to the computer hosting the instance of SQL Server.

Start SQL Server Configuration Manager.

In the left pane, select SQL Server Services.

In the right pane, verify the name of the instance of the database engine.

  • SQL SERVER (MSSQLSERVER) indicates a default instance of SQL Server. The name of the default instance is .
  • SQL SERVER ( ) indicates a named instance of SQL Server. The name of the named instance is .

Get the IP address of the server

You can use the following steps to get the IP address of the computer hosting the instance of SQL Server.

On the Start menu, select Run. In the Run window, type cmd, and then select OK.

In the Command Prompt window, type ipconfig/all and then press Enter. Note down the IPv4 address and the IPv6 address.

SQL Server can connect by using either IP version 4 protocol or IP version 6 protocol. Your network could allow either or both.

Get the TCP port of the instance

In most cases, you connect to the Database Engine on another computer by using the TCP protocol. To get the TCP port of the instance, follow these steps:

Use SQL Server Management Studio on the computer running SQL Server and connect to the instance of SQL Server. In Object Explorer, expand Management, expand SQL Server Logs, and then double-click the current log.

In the Log File Viewer, select Filter on the toolbar. In the Message contains text box, type server is listening on, select Apply filter, and then select OK.

A message like Server is listening on [ ‘any’ 1433] should be listed.

This message indicates that the instance of SQL Server is listening on all IP addresses on this computer (for IP version 4) and TCP port 1433. (TCP port 1433 is usually the port that’s used by the Database Engine or the default instance of SQL Server. Only one instance of SQL Server can use this port. If more than one instance of SQL Server is installed, some instances must use other port numbers.) Note down the port number used by the SQL Server instance that you’re trying to connect to.

  • IP address 127.0.0.1 is probably listed. It’s called the loopback adapter address. Only processes on the same computer can use the IP address to connect.
  • You can also view the SQL Server error log by using a text editor. By default, the error log is located at Program FilesMicrosoft SQL ServerMSSQL.nMSSQLLOGERRORLOG and ERRORLOG.n files. For more information, see Viewing the SQL Server error log.

Step 1пјљVerify that the instance is running

Option 1: Using the output file from the SQLCheck tool

Search the output from SQLCheck file for «SQL Server Information».

In the section titled «Services of Interest», find your SQL Server instance under Name and Instance (for named instances) columns and check its status by using Started column. If the value is True, the services are started. Otherwise the service is currently not running.

If the service isn’t running, start the service by using either SQL Server management studio, SQL Server Configuration manager, PowerShell, or Services applet.

Option 2: Use SQL Server Configuration Manager

To verify that the instance is running, select SQL Server Services in SQL Server Configuration Manager and check the symbol by the SQL Server instance.

  • A green arrow indicates that an instance is running.
  • A red square indicates that an instance is stopped.

If the instance is stopped, right-click the instance and select Start. Then, the server instance starts, and the indicator becomes a green arrow.

Option 3: Use PowerShell commands

You can use the following command in PowerShell to check the status of SQL Server services on the system:

You can use the following command to search the error log file for the specific string «SQL Server is now ready for client connections. This is an informational message; no user action is required.»:

Step 2: Verify that the SQL Server Browser service is running

This step is required only for troubleshooting connectivity issues with named instances.

Option 1: Using the output file from SQLCheck tool

Search the output from SQLCheck file for «SQL Server Information».

In the section titled «Services of Interest», search for SQLBrowser in the Name column and check its status using the Started column. If the value is True, the service is started. Otherwise, the service is currently not running, and you need to start it. For more information, see Start, stop, pause, resume, restart SQL Server services.

Option 2: Use SQL Server Configuration Manager

To connect to a named instance, the SQL Server Browser service must be running. In SQL Server Configuration Manager, locate the SQL Server Browser service and verify that it’s running. If it’s not running, start the service. The SQL Server Browser service isn’t required for default instances.

For more information on using SQL Server Browser service in your environment, see SQL Server Browser service.

For more information on stopping and starting SQL Services, see Start, stop, pause, resume, restart SQL Server services.

If you can’t have the SQL Server Browser service running in your environment, see Connecting to SQL server named instance without SQL Server browser service.

Step 3: Verify the server name in the connection string

You often encounter errors when an incorrect server name is specified in the connection string. Make sure that the server name matches the one that you retrieved in the previous steps.

If you are using the SQLCheck tool, review the NetBios Name/FQDN values in the Computer Information section of the output file.

  • For examples on connection strings, see SQL Server Connection Strings.
  • For more detailed examples, see Proof of concept connecting to SQL using ADO.NET under Homepage for SQL client programming.

Step 4: Verify the aliases on the client machines

Aliases are often used in client environments when you connect to SQL Server with an alternate name or when there are name resolution issues in the network. They’re created by using SQL Server Configuration Manager or client network utility. An incorrect alias can cause the connections from your applications to connect to the wrong server, resulting in failure. Use the following methods to check for incorrect aliases. You can also use a tool (such as SQLCHECK) on the client machine to check for aliases and various other connectivity-related settings on a client machine.

The following options only apply to the applications that use SQL Server Native Client to connect to SQL Server.

Option 1: Using the output file from the SQLCheck tool

In the SQLCheck output file, search for the string SQL Aliases. (This string will be inside the Client Security and Driver Information section of the file)

Review the entries in the table. If there’s none present, there are no aliases on the computer. If there’s an entry, review the information to ensure the server name and port number are set to the correct values.

Example output:
SQL Aliases:

The above indicates that prodsql is an alias for a SQL Server called prod_sqlserver that is running on port 1430.

Option 2: Check aliases in SQL Server Configuration Manager

  1. In SQL Server Configuration Manager, expand SQL Server Native Client Configuration, and select Aliases.
  2. Check whether any aliases are defined for the server that you’re trying to connect to. If the aliases exist, follow these steps:
    1. Open the Properties pane of the alias.
    2. Rename the value in the Alias Name field (for example, if your server name is MySQL, rename it as MySQL_test) and retry the connection. If the connection works, your alias is incorrect and may come from an old configuration that is no longer needed. If the connection doesn’t work, rename the alias back to its original name and go to the next step.
    3. Check the connection parameters for the alias and make sure that they’re correct. The following common scenarios can cause connectivity problems:

    Incorrect IP address for the Server field. Make sure that the IP address matches the entry in the SQL Server error log file.

    Incorrect server name in the Server field. For example, your server alias points to the correct server name. However, the connections will fail if the value of the server name parameter is incorrect.

    Incorrect pipe name format (assuming that you use a named pipes alias).

    • When connecting to a default instance named Mydefaultinstance, the pipe name should be \Mydefaultinstancepipesqlquery.
    • When connecting to a named instance MySQLNamed, the pipe name should be \MySQLpipeMSSQL$Namedsqlquery.

Option 3: Check aliases in SQL Server Client Network Utility

  1. Open SQL Server Client Network Utility by typing cliconfg.exe in your Run command.
  2. Follow step 2 in Option 2: Check aliases in SQL Server Configuration Manager.

Step 5: Verify the firewall configuration

You can verify the firewall configuration depending on the default instance or named instance.

If you are using third party firewalls in your network, the concepts still apply. However, you may have to work with your network administrator or consult the firewall product’s documentation for more information on configuring the firewall to allow necessary ports for communication with SQL Server.

Default instance of SQL Server

A default instance typically runs on port 1433. Some installations also use a non-standard port (other than 1433) to run SQL instances. The firewall may block either port. To check the port number further, follow these steps:

  1. Determine the port your SQL instance is running on, see Get the TCP port of the instance.

    If your SQL Server is configured to listen on port 1433, make sure that firewalls on the network between the client and the server allow traffic on that port. Review Configure a Windows Firewall for Database Engine Access and work with your network administrator to implement necessary solutions.

    If your SQL Server default instance isn’t using 1433, try to append the port number of SQL Server to the server name by using the format ,

    and see whether it works. For example, your SQL instance name is MySQLDefaultinstance and it’s running on port 2000. Specify the server name as MySQLServer, 2000 and see whether it works.

    If it doesn’t work, it indicates the firewall is blocking the port. You can follow the instructions at Configure a Windows Firewall for Database Engine Access or work with your network administrator to add the port to the firewall exclusion list.

    • If it does work, it indicates that the firewall is allowing communication through that port. You need to change your connection string in order to use the port number and your server name in the connection string of your application.

Named instance of SQL Server

If your SQL instance is a named instance, it may be configured to use either dynamic ports or a static port. In either case, the underlying network libraries query the SQL Server Browser service running on your SQL Server machine through UDP port 1434 to enumerate the port number for the named instance. If a firewall between the client and the server blocks this UDP port, the client library can’t determine the port (a requirement for connection) and the connection fails. To check the connection, you can use one of the following methods:

Method 1: Check connection by specifying the port number in your connection string.

Determine the port your SQL instance is running on, see Get the TCP port of the instance.

Try to connect to the named instance by using the port number appended to the server name in the format ,

and see if that works. For example, if your SQL instance name is MySQLNamedinstance and it’s running on port 3000, specify the server name as MySQLNamedinstance,3000.

If it does work, it indicates the firewall is blocking the UDP port 1434 or the instance is hidden from SQL Server Browser.

If it doesn’t work, it indicates one of the following situations:

Either UDP port 1434 is blocked or the static port is blocked, or both. To confirm whether it’s the UDP port or the static port, use Portqry.

The instance is hidden from the SQL Server Browser service.

Method 2: Check the connection by using the PortQryUI tool.

Use the PortQryUI tool with your named instance and observe the resulting output. You may see a message that the UDP port 1434 is filtered. This message indicates that the port is blocked on the network. For instructions on how to use the tool, see Using the PortQryUI Tool with SQL Server.

Determine whether the SQL Server instance is listening on dynamic or static ports. Then use the following method that is relevant to your scenario. If you aren’t sure, see How to check if SQL Server is listening on a dynamic port or static port.

Scenario 1: Dynamic ports. In this case, ensure that the SQL Server Browser service is started and UDP port 1434 isn’t blocked on the firewall between the client and the server. If you can’t do either of these things, you should switch your SQL Server instance to a static port and use the procedure documented in Configure a Server to Listen on a Specific TCP Port.

Scenario 2: Static port configuration. Either SQL Server Browser isn’t running or UDP 1434 can’t be opened on the firewall. In this case, make sure to specify the static port in your connection string and that the firewall doesn’t block the port. For more information, review Configure a Windows Firewall for Database Engine Access.

Step 6: Verify the enabled protocols on SQL Server

In some installations of SQL Server, connections to the Database Engine from another computer aren’t enabled unless an administrator manually enables them. You can use one of the following options to check and enable the necessary protocols to allow remote connections to SQL Server Database Engine.

Option 1: Using the output file from SQLCheck tool

Search the SQLCheck output file for «Details for SQL Server instance» section and locate the information section for your SQL Server instance.

In the section, find the values listed in the following table to determine if the SQL Server protocols are enabled:

Value name Implication More information
Shared Memory Enabled Can either be true of false — only affects local connections. Creating a Valid Connection String Using Shared Memory Protocol
Named Pipes Enabled If false, both local and remote connections using Named pipes will fail Choosing a Network Protocol
TCP Enabled If false, both local and remote connections using TCP/IP will fail.
Note The majority of the SQL Server installations use TCP/IP as the communication protocol between server and the client.
Choosing a Network Protocol

Enable required protocols by using SQL Server Configuration Manager or SQL Server PowerShell. For more information, see Enable or Disable a Server Network Protocol.

After enabling a protocol, the Database Engine must be stopped and restarted for the change to take effect.

Option 2: Use SQL Server Configuration Manager

To enable connections from another computer by using the SQL Server Configuration Manager, follow these steps:

Open the SQL Server Configuration Manager.

In the left pane, expand SQL Server Network Configuration, and then select the instance of SQL Server that you want to connect to. The right pane lists the connection protocols available. Shared Memory is normally enabled. It can only be used from the same computer, so most installations leave Shared Memory enabled. To connect to SQL Server from another computer, use TCP/IP. If TCP/IP isn’t enabled, right-click TCP/IP, and then select Enable.

If you change the enabled setting for any protocol, restart the Database Engine. In the left pane, select SQL Server Services. In the right-pane, right-click the instance of the Database Engine, and then select Restart.

Step 7: Test TCP/IP connectivity

Connecting to SQL Server by using TCP/IP requires that Windows establish the connection. You can use the following steps to test TCP connectivity by using the ping tool.

On the Start menu, select Run. In the Run window, type cmd and select OK.

In the Command Prompt window, type ping and the IP address of the computer that’s running SQL Server. For example:

  • IPv4: ping 192.168.1.101
  • IPv6: ping fe80::d51d:5ab5:6f09:8f48%11

If your network is configured properly, ping returns Reply from followed by some additional information. If ping returns Destination host unreachable or Request timed out , TCP/IP isn’t correctly configured. Errors at this point indicate a problem with the client computer, the server computer, or something about the network such as a router. To troubleshoot network problems, see Advanced troubleshooting for TCP/IP issues.

If the ping test succeeds by using the IP address, test whether the computer name can be resolved to the TCP/IP address. On the client computer, in the Command Prompt window, type ping and the name of the computer that’s running SQL Server. For example, ping newofficepc .

If ping to the IP address succeeds, but ping to the computer name returns Destination host unreachable or Request timed out , you might have old (stale) name resolution information cached on the client computer. Type ipconfig /flushdns to clear the DNS (Dynamic Name Resolution) cache. Then ping the computer by name again. When the DNS cache is empty, the client computer checks the latest information about the IP address for the server computer.

If your network is configured properly, ping returns Reply from followed by some additional information. If you can successfully ping the server computer by IP address but receive an error such as Destination host unreachable or Request timed out when pinging by computer name, then name resolution isn’t correctly configured. For more information, see how to Troubleshoot Basic TCP/IP Problems. Successful name resolution isn’t required to connect to SQL Server. However, if the computer name can’t be resolved to an IP address, connections must be made to specify the IP address. Name resolution can be fixed later.

You can also use either Test-NetConnection or Test-Connection cmdlet to test TCP connectivity according to the PowerShell version that’s installed on the computer. For more information on PowerShell cmdlet, see Cmdlet Overview.

Step 8: Test local connection

Before troubleshooting a connection problem from another computer, test your ability to connect from a client application installed locally on the computer that is running SQL Server. Local connection avoids issues with networks and firewalls.

This procedure requires SQL Server Management Studio. If you don’t have Management Studio installed, see Download SQL Server Management Studio (SSMS).

If you can’t install Management Studio, you can test the connection by using the sqlcmd.exe utility. sqlcmd.exe is installed with the Database Engine. For information about sqlcmd.exe, see sqlcmd Utility.

Sign in to the computer where SQL Server is installed by using a login that can access SQL Server. During installation, SQL Server requires at least one login to be specified as a SQL Server administrator. If you don’t know an administrator, see Connect to SQL Server When System Administrators Are Locked Out.

On the Start page, type SQL Server Management Studio, or on the Start menu of the older versions of Windows, select All Programs, select Microsoft SQL Server, and then select SQL Server Management Studio.

On the Connect drop-down menu, select Database Engine. In the Authentication box, select Windows Authentication. In the Server name box, type one of the following connection types:

Connecting to Type Example
Default instance ACCNT27
Named Instance ACCNT27PAYROLL

When connecting to SQL Server from a client application on the same computer, the shared memory protocol is used. Shared memory is a type of local named pipe, so you sometimes encounter errors related to pipes.

If you receive an error at this point, you must resolve it before proceeding. Your login might not be authorized to connect. Your default database might be missing.

You can’t troubleshoot the problem without enough information because some error messages are passed to the client intentionally. This is a security feature to avoid providing an attacker with information about SQL Server. To view the details about the error, see the SQL Server error log.

If you receive error 18456 Login failed for user, Books Online article MSSQLSERVER_18456 contains additional information about error codes. Aaron Bertrand’s blog also has an extensive list of error codes at Troubleshooting Error 18456 (external link). You can view the error log by using SSMS (if you can connect), in the Management section of the Object Explorer. Otherwise, you can view the error log with the Windows Notepad program. The default location varies with your version and can be changed during setup. The default location for SQL Server 2019 (15.x) is C:Program FilesMicrosoft SQL ServerMSSQL15.MSSQLSERVERMSSQLLogERRORLOG.

If you can connect by using shared memory, test connecting by using TCP. You can force a TCP connection by specifying tcp: before the name. Here are the examples:

Connecting to: Type: Example:
Default instance tcp: tcp:ACCNT27
Named Instance tcp: tcp:ACCNT27PAYROLL

If you can connect by using shared memory but not TCP, you must fix the TCP problem. The most likely issue is that TCP isn’t enabled. To enable TCP, see Step 6: Verify the enabled protocols on SQL Server.

If your goal is to connect by using an account other than an administrator account, you can begin by connecting as an administrator. Then, try to connect again with the Windows Authentication login or the SQL Server Authentication login that the client application uses.

Step 9: Test remote connection

Once you can connect by using TCP on the same computer, it’s time to try to connect from the client computer. You could use any client application, but to avoid complexity, install the SQL Server Management tools on the client. After installation, try to use SQL Server Management Studio.

Use SQL Server Management Studio on the client computer and try to connect by using the IP address and the TCP port number in the format IP address comma port number. For example, 192.168.1.101,1433 . If this connection fails, you probably have one of the following problems:

ping of the IP address doesn’t work. This indicates a general TCP configuration problem. Go back to the section Step 7: Test TCP/IP connectivity.

SQL Server isn’t listening on the TCP protocol. Go back to the section Step 6: Verify the enabled protocols on SQL Server.

SQL Server is listening on a port other than the port that you specified. Go back to the section Get the TCP port.

The SQL Server TCP port is being blocked by the firewall. Go back to the section step 5: Verify the firewall configuration.

Once you can connect by using the IP address and port number, review the following scenarios:

If you connect to a default instance that is listening on any port other than 1433, you must use either the port number in the connection string or create an alias on the client machine to connect to the default instance. The SQL Server Browser service can’t enumerate ports of the default instance.

If you connect to a named instance, try to connect to the instance in the format IP address backslash instance name. (For example, 192.168.1.101 .) If this action doesn’t work, it means that the port number isn’t being returned to the client. The problem is related to the SQL Server Browser service, which provides the port number of a named instance to the client. Here are the solutions:

  • Start the SQL Server Browser service. See the instructions to start browser in SQL Server Configuration Manager.
  • The SQL Server Browser service is being blocked by the firewall. Open UDP port 1434 in the firewall. Go back to the section Step 5: Verify the firewall configuration. Make sure that you’re opening a UDP port, not a TCP port.
  • The UDP port 1434 information is being blocked by a router. UDP communication (user datagram protocol) isn’t designed to pass through routers and keeps the network from getting filled with low-priority traffic. You can configure your router to forward UDP traffic, or you can provide the port number every time you connect.
  • If the client computer is using Windows 7, Windows Server 2008, or a more recent operating system, the client operating system might drop the UDP traffic because the response from the server is returned from a different IP address that was queried. This action is a security feature blocking «loose source mapping.» For more information, see the Multiple Server IP Addresses section of the Books Online article Troubleshooting: Timeout Expired. (This article is from SQL Server 2008 R2, but the principals still apply. You can configure the client to use the correct IP address or provide the port number every time you connect.)

Once you can connect by using the IP address (or IP address and instance name for a named instance), try to connect by using the computer name (or computer name and instance name for a named instance). Put tcp: in front of the computer name to force a TCP/IP connection. For example, for the default instance on a computer named ACCNT27, use tcp:ACCNT27 . For a named instance called PAYROLL, on that computer use tcp:ACCNT27PAYROLL . If you can connect by using the IP address but not by using the computer name, you have a name resolution problem. Go back to the section Step 7: Test TCP/IP connectivity.

Once you can connect by using the computer name forcing TCP, try to connect by using the computer name without forcing TCP. For example, for a default instance, and just use a computer name such as CCNT27. For a named instance, use the computer name and instance name like ACCNT27PAYROLL. If you can connect while forcing TCP, but not without forcing TCP, the client is probably using another protocol such as named pipes. To fix this issue, follow the steps:

  1. On the client computer, use SQL Server Configuration Manager. In the left-pane, expand SQL Native Client Configuration, and then select Client Protocols.
  2. On the right-pane, make sure that TCP/IP is enabled. If TCP/IP is disabled, right-click TCP/IP and select Enable.
  3. Make sure that the protocol order for TCP/IP is a smaller number than the named pipes (or VIA on older versions) protocols. Generally, you should leave shared memory as order 1 and TCP/IP as order 2. Shared memory is only used when the client and SQL Server are running on the same computer. All enabled protocols are tried in order until one succeeds, but shared memory is skipped when the connection isn’t on the same computer.

Источник

SQL Server Error 26 and SQL Server Error 40 appear when you try to connect to SQL Server. We will troubleshoot and try to fix them in the same article as both are related to connection issue. We recommend to use the below solutions for the both errors and to try to localize the problem.

The error Messages:

(provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)

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: 26 – Error Locating Server/Instance Specified)

“ Named Pipes Provider Error: 40 – Could not open a connection to SQL Server“.

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)

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 the SQL Server is configured to allow remote connections. (provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server) (Microsoft SQL Server, Error: 2).

sql server error 26

sql server error 26

SQL Server Error 26 and SQL Server Error 40

What is SQL Server Error 26?

You will get this error message while trying to connect to a SQL Server named instance and not when you use default instance. The client stack could not receive SSRP response UDP packet from SQL Browser.

How to fix Error 26 on SQL Server?

  1. Recheck the server name for any error and fix it
  2. Check the instance name for any error
  3. Check if SQL Server browser is running
  4. Control if this instance exist on server
  5. Ping the server and check if DNS can be resolved correctly

What is SQL Server Error 40?

This error appears mostly when SQL Server does not allow remote connections, Firewall Settings or TCP/IP is not enabled. We will explain below all those in order to troubleshoot easy.

Read also other SQL Server Helping Posts:

  1. How to fix SQL Server Error 229
  2. Fix SQL Server Error 233
  3. SQL Server Error 17002

How to fix error 40 on SQL Server?

  1. Check SQL Server is running
  2. Make sure that Allow Remote Connections is enabled on sql server properties
  3. Check if TCP/IP is enabled
  4. Configure to allow SQL Server in Firewall Settings
  5. Check for working fine SQL Server Browser
  6. Make sure that you can ping the SQL Server

Below we will explain the above steps in long way for better understanding and easy fix of SQL error 26 and sql error 40.

1. Check if SQL Services are running

Hint! If you are running SQL Server by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections.

How to check if SQL Server Service is running?

  • Go to SQL Server Configuration Manager > SQL Server Services
  • Find the service SQL Server (MSSQLSERVER) if default or the name of your instance
  • Check if is running – should be running state with a green indication

Using Windows Command Prompt

sc query mssqlserver

For named instance name use below by by replacing instancename with the actual SQL Server instance name.

sc query mssql$instancename

How to check if SQL Server Browser is running?

  • Navigate to SQL Server Configuration Manager > SQL Server Services
  • Find the SQL Server Browser Service
  • Check if it is configured to start automatically and is started – should be with a green indication

Using Windows Command Prompt

sc query sqlbrowser

Check if SQL Server Service

Check if SQL Server Service

2. Try to Flush DNS

How to flush DNS?

  1. Click Start Button
  2. Type CMD and press enter
  3. Type this into the black window that appears: ipconfig /flushdns and press enter.

Fluish DNS

Fluish DNS

3. Make sure that allow Remote Connection is enabled

Check if remote connections is allowed for applications/client. This option need to be allowed to establish connections and perform operations on the server. Often this is the reason of SQL Server Error 26 and SQL Server Error 40.

How to check if the remote connection is enabled?

  1. Open ‘SQL Server Management Studio’
  2. Right click on database name and select ‘Properties’
  3. In ‘Properties’ window, select ‘Security’, enable `SQL Server and Windows Authentication mode` and click `OK`.
  4. Now restart the SQL server.

Allow Remote Connections

Allow Remote Connections

4. Check Firewall

Check the firewall status for any troubles:

  1. Open ‘Control Panel’ and after that ‘Windows Firewall’.
  2. Select ‘Change Settings’ In ‘Windows Firewall’,
  3. Add an exception for port ‘1434’ and name it ‘SQL Server’
  4. Enable by clicking on the checkbox

5. Connection String

This solution is on cases when you are using connection string and are you writing it wrongly. For example connection string used by .NET framework:

Server=serverAddress;Database=dbName;User Id=username;

Password=password;

  1. Check for each parameter passed in the connection string for any typographical errors.
  2. Control the validity of the username/password.
  3. Confirm if the given database exists.

6. TCPIP Protocol

This solutions can work when you have mix of default and named instance or named instances only.

How to Enable TCP/IP port?

  1. Open SQL Server Configuration Manager
  2. Click on SQL Server Network Configuration and click on Protocols for Name
  3. Right-click on TCP/IP
  4. Click Enable
  5. Restart your SQL Server instance

Enable TCP-Ip port

Enable TCP-Ip port

If you want to use a static port for your instance (instead of dynamic that changes after every restart) you can change it here.

  1. Open Properties for TCP/IP protocol
  2. Go to IP Addresses tab
  3. Scroll down to IPAll section
  4. Remove 0 value from TCP Dynamic Ports
  5. Specify your port in TCP Port

You can use this port to connect to your instance by providing <servername>,<port> or <IP>,<port> as Server Name (yes, there is a comma, not a colon).

TCP-Ip static port

TCP-Ip static port

Conclusion:

We have explained some solutions to fix SQL Server Error 26 and SQL Server Error 40 and hope that you find the fix on those solutions. The both errors are included on the same article because they have almost the same troubleshoot. If you have any other solution worked for you comment below and we will try to include it on our article.

Ultimate Solutions to Resolve MS SQL Server Error 2

Have you ever wonder that you are in a hurry and has to make changes in SQL database but, you end up on an error?

Certainly, It is not less than a nightmare.

The similar condition happens when users try to use SQL Server with the help of Microsoft SQL Server Management Studio and get the following 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 the SQL Server is configured to allow remote connections. (provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server) (Microsoft SQL Server, Error: 2).

It is a disturbing scenario where the user needs to connect with database and get the SQL Server Management error. Without resolving this technical glitch, you cannot use the database in SSMS. Thus considering the users’ situation, we come up with this article. Here, we will describe some workarounds that let you know how to solve Microsoft SQL Server Error 2 step-by-step. Along with this, we will also illustrate the reason behind this SSMS error.

So, let’s get started!!

Microsoft SQL Server Error 2 Could Not Open Connection : Potential Reasons

In the subsequent section, all the factors that are responsible for SSMS Error i.e., A network-related or instance-specific error occurred while establishing a connection to SQL Server discussed below.

  1. It might be possible that SQL Server Services are disabled that
    created an issue while connecting to SQL Server Management Studio.
  2. Check whether you are using right SQL Server instance name at the
    time of connection.
  3. SQL Administrator does not provide permission to Allow remote
    connection.
  4. It is also possible that SQL Server Management Studio using the
    incorrect port number. That is why user will get the MS
    SQL Server Error 2.
  5. The SQL Server Browser service is not enabled under the SQL Server
    Configuration Manager.
  6. It also happens, the port on which SQL Server is running, is blocked
    by system firewall.
  7. The Named Pipes protocol is disabled in SQL Server Configuration
    Manager. Originally, the Named Pipes is a type of protocol developed
    for Local Area Networks in order to communicate between two
    processes.

After understanding the factors behind this error, let’s go through the techniques to fix the SQL Server Error 2 of SSMS.

Microsoft SQL Server Error 2 Solutions – 100% Working

It is important to analyze the correct reason behind the SSMS error. After knowing the reason, execute the workaround according to it.

Method #1: Enable the SQL Server Services

Step 1: Initially, press the Windows key along with R key in order to open the Run box.

Step 2: Input the ‘compmgmt.msc’ under the Open box as shown in the screenshot. Then, click on OK to execute it.

Step 3: From Computer Management window, click on Services and Applications >> SQL Server Configuration.

Step 4: Afterward, opt for SQL Server Services from the preview pane.

Step 5: Once you select the option, the 6 different services of SQL Server available on the screen along with its State.

Step 6: At last, you need to start the services.

Method #2: Enable TCP/IP Network Protocol for SQL Server 2014 / 2016 / 2017

Step 1: From Computer Management window, click on Services and Applications >> SQL Server Configuration Manager >> SQL Native Client 11.0 Configuration (32 bit).

Step 2: Under SQL Native Client 11.0 Configuration (32 bit) option, opt for Client Protocols option. By doing this, you will see the three protocols – Shared Memory, TCP/IP, Named Pipes. If anyone is disabled make them enabled. For this, right-click on any protocol and click on Enable.

Step 3: Try to connect with SQL Server via SQL Server Management Studio and see whether the Microsoft SQL Server Error 2 get resolved or not.

Method #3: Provide Permission of Allow Remote Connections

Step 1: Open Microsoft SQL Server Management Studio. Here, we are using SSMS 2014 on Windows 10 OS.

Step 2: Go to the Server Name under the Object Explorer. Afterward, right-click on it and opt for Properties.

Step 3: Under Server Properties window, go to the Connections section and check the box corresponding to Allow remote connections to this server. Then, hit the OK button to resolve SSMS error 2.

Bringing It All Together

If for any reason – users face the Microsoft SQL Server Error 2 Cannot Connect to Local in SSMS then, try the above-mentioned workarounds. Although, many times SQL Server error arises due to corruption in MDF file. In such a situation, try the SysTools SQL Database Recovery Software. Hence, it is a complete guide that let users know how to fix MS SQL Error 2 on the Windows platform.

Frequently Asked Question of Users

Q – How do I allow SQL Server to allow remote connections ?

A – To enable remote location, do this.
1. Connect to SQL Server Management Studio.
2. Right-click your server’s name and opt Properties.
3. check the box adjacent to Allow remote connections to this server and click OK.

Q – Why am I getting a network related or instance specific error in SQL Server 2017 ?

A – Check whether all your SQL Server services are enable or not.

Q – How do I fix Microsoft SQL Server error 2 named pipes provider error 40 ?

A – You should enable your SQL Server services and TCP/IP network protocol. Still, it is not fix then, allow the remote location.

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Network receive roblox как исправить
  • Network read error connection reset by peer
  • Network plugin returns error cni plugin not initialized
  • Network nwerror error 0 altstore
  • Network name resolution error

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии