wesupport

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

SQL server error 40 – Different ways to fix it

by | Sep 14, 2020

The error ‘SQL server error 40’ occurs while we try to connect to the SQL Server.

Here at Bobcares, we have seen several such SQL related issues as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at the cause for this error and see how to fix it.

 

What causes the error ‘SQL server error 40’ to occur

Here are the different causes of this error to occur.

  • Connection to the server instance fails
  • Using wrong default settings
  • SQL Server doesn’t have enough permissions to allow the remote connection.
  • The problem in firewall settings

 

How we fix ‘SQL server error 40’

Now let’s take a look at the various fixes to resolve this error.

 

1. If the SQL Server instance is not running.

Now go to Services option and click on SQL Server installed in your system. If its status is not ‘Started’, then start it by clicking on the START option.

 

2. Enabling TCP/IP

Ensure that the TCP/IP is enabled on the server. In case, if it is not enabled then follow the below steps to enable it.

First, click on the Configuration Manager of SQL Server.
Check if the TCP/IP port status is enabled or not. If not, then you would need to enable it and then click on the status to change the port properties.
Now enter the Default Port number 1433 and click on the OK button.

 

3. Allow Remote Connections enabled under Connections in SQL Server Properties.

Below are the steps to enable it.

First, open the SQL Management Studio and then right-click on the Server Name.
Now, click on the Server Properties. Then under the Connections Options, check the box of ‘Allow remote connections to this server’ and then click on the OK button.

 

4. Allow SQL Server in Firewall Settings:

Add a Windows Firewall exception on the server for SQL TCP ports 1433 and 1434, so that SQL Server will run. Here are the steps to do the same.

First, go to Control Panel then System and Security, or directly search it on your system search as Windows Firewall.
Now, click on the Firewall. Here you can see the Action tab as Allow for Firewall. You can change it through SQL Server Properties to allow or block.

 

5. Verify whether the SQL server is reachable using ping

Ensure that you are able to ping the physical server where SQL Server is installed from the client machine. If you are not able to then you can try to connect to the SQL Server using an IP Address (for default instance) or IP Address\Instance Name for a named instance.

 

6. Verify whether SQL Server Browser service is running or not

It is important for the SQL Server Browser service to be running well. So make sure that it is running well.
However, if you have installed a SQL Server named instance and not configured a specific TCP/IP port then the incoming requests will be listening on a dynamic port.
In order to resolve this, you would need to have the SQL SQL Server Browser service enabled and running. Moreover, you can check the status of browser service using either SQL Server Configuration Manager or the SC command as below:

sc query sqlbrowser

Also, make sure to add an exception for sqlbrowser.exe in the firewall.

 

7. Confirm that you are using the right SQL Server instance name

Ensure that you are using the right instance name. Whenever you connect to a default instance, machinename is the best representative for the instance name. However, when you connect to a named instance such as sqlexpress, you would need to specify the instancename as machinename\instancename where you enter the SQL Server instance name for instancename.

 

8. Verify the port number that SQL Server is using

In order to verify the port number, locally connect to the SQL Server and check the error log for the port entry. You can verify this in SSMS. Below are the steps for the same.

Access the Management in SSMS
Now, go to SQL Server Logs and select the Current log.
Scroll down to the bottom which will be the first entry in the error log and look for entries to check whether Named Pipes and TCP/IP are enabled and the port used for TCP/IP.

[Need any further assistance in fixing SQL errors? – We’re available 24*7]

 

Conclusion

In short, this error occurs while we try to connect to the SQL Server. Today, we saw how to fix this SQL error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags