MS SQL connection troubleshooting

This guide is intended to give you hints, that might help you fix a broken Microsoft SQL Server or Microsoft SQL Express connection. In general, a reinstallation of the database server usually fixes the problem, but in most cases reinstallation is not an option. Here are the things to check if you cannot connect to your SQL server:

1. Please use the SQL Server configuration manager to check if both TCPIP and Named Pipes are enabled for the database server instance.

2. Make sure SQLBrowser service is up and running.

3. Check if the TCPIP and Named Pipe protocols are enabled to be used in the SQL Client.

4. Open the error log to find the SQL database instance and make sure there are no ERROR messages for TCPIP and Named Pipes. The logs can be found at: C:\Program Files\Microsoft SQL Server\MSSQL.x\MSSQL\LOG

5. You should also find the port number, and check if the port number configured in the server and client are identical.

6. Please try different protocols by testing them with 'sqlcmd'. One of the following 'sqlcmd' commands should work.

sqlcmd -S np:\\127.0.0.1\pipe\MSSQL$instancename\sql\query
sqlcmd -S tcp:servername\instancename
sqlcmd -S tcp:servername\instancename,portnumber

Tip: Check that you use the correct servername, instancename and portnumber for your database server.

7. If it is still not possible to connect, please change this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer

LoginMode=2

More information