How To: Troubleshoot SQL Connection
This article discusses issues relating to connecting to a SQL database.
Could not connect to the database or #DBCONNECT!
When attempting to connect to a SQL database that is hosted on a network you may get the message:
- Could not connect to the database
Or
- #DBCONNECT!
The following may resolve connection issues.
Ensure SQL Services are running and have the correct permissions
On the machine hosting the SQL database:
- Open Windows Services (in the Windows search type Services).
- Scroll down the list of installed Services until you see the following:
- SQL Server (suffixed with the installed edition)
- SQL Server Browser (suffixed with the installed edition)
- Ensure the status of both of the above are Running and the Startup Type is Automatic.
To change the Status:
- Select the Service from the list of services.
- Select the link to Start the service.
To change the Startup Type:
- Select the Service from the list of services.
- Right click and select Properties.
- From the General tab change the Startup Type to Automatic.
This will ensure that if the machine reboots the service will start automatically.
To check permissions:
- Select the Service from the list of services.
- Right click and select Properties.
- From the Log On tab ensure Local System account is selected.
This ensures the account used to log onto the machine, hosting SQL, can access the database.
Enable Remote Access for SQL Server
It could be that SQL Server is not configured for remote access.
To change this setting please refer to the article How To: Configure SQL Server for Remote Access.
Check if Windows Firewall is blocking the connection
The advice below is specifically for Windows Defender Firewall.
Other Firewalls will have similar features to diagnose SQL connection issues.
Temporarily turn off Windows Firewall:
This is a temporary measure only to determine if Firewall is the issue.
Please restore the Firewall to its original state once troubleshooting has been done.
- Open Windows Defender Firewall.
- Click the link to Turn Windows Defender Firewall on or off.
- Select the options to Turn off Windows Defender Firewall for each type of network that you use.
- Test connection to SQL Server can now be established from the machine it previously failed on.
Configure Windows Firewall:
If connection to the SQL Server is now available, Windows Firewall can be turned back on and configured to allow access to SQL Server.
There are two methods for configuring Windows Firewall for SQL Server.
Choose one of the two methods below, that best suits your IT policy:
Knowledge Base Article Ref: | KB13103032 |
---|