Bobcares

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 *

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

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF