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.

MSSQL error 40 – How to fix it

by | Oct 1, 2019

Database errors can be frustrating. Especially when even the login to the SQL Server fails.

Usually, the MSSQL error 40 occurs when a user can’t connect to the SQL server.

At Bobcares, we often receive requests to fix MSSQL error 40 as part of our Server Management Services.

Today, let’s analyze the error and see how our Support Engineers fix it for our customers.

 

Causes for the error MSSQL Error 40

Now, let’s get into the details of the “Error: 40 – Could not open a connection to SQL Server“.

This error primarily happens when there are problems establishing database connection. The common causes for the error are MSSQL service failure or the closed MSSQL port.

 

How we fix MSSQL error 40

We just saw on what causes the MSSQL error 40.

We’ll now take a look at different error scenarios and how we fix the MSSQL error.

 

1. SQL service down

Recently, we had a customer who was facing a problem to get into the database. We helped him to fix the error by verifying the following details.

The most common reason that can cause the error was SQL service failure.

Therefore, we first verified whether the service was running. We verified the service from

Click Start >> Search services.

Here the server was in a stopped state. So we did a restart of the service. Also, we made sure that the SQL Server Agent was running.

In a similar way, the SQL service can also be verified from the command prompt. To do this, our Support Engineers use the command.

sc query mssqlserver
sc query sqlserveragent

 

2. Enable TCP/IP

Another common reason for the error can be disabling of TCP/IP protocol on the server.

Here, our Dedicated Engineers verify the details and enable TCP/IP.

We enable TCP/IP from the SQL server configuration manager.

Open SQL server configuration manager >> Expand SQL server network configuration >> Right click on TCP/IP >> Enable.

We will also verify the port mentioned in TCP/IP. By default, MSSQL runs on port 1433. We always make sure that the server listens correctly on the port.

 

3. Port not open in the firewall

In most cases, when the SQL service is running and the server has TCP/IP enabled, there should not be any errors.

However, if still the error happens our Support Engineers analyze the firewall setting in the server. The SQL port 1433 must be open on the server. If the port is not open, we open it in the Windows firewall.

Start >> Administrative Tools >> Windows Firewall with Advanced Security

Click on outbound rules >> Select new rule.

Now our engineers will add the rule to open MSSQL port.

That fixes the MSSQL error 40.

[Need assistance to fix MSSQL errors? We’ll help you.]

 

Conclusion

In short, MSSQL error 40 happens due to a lack of connection to the server. Today, we discussed how our Support Engineers fix the error by verifying the service and enabling the port 1433 in the server.

0 Comments

Submit a Comment

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

Categories

Tags

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

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

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