Home » Blog » SQL Server » How to Fix SQL Server Does Not Exist or Access Denied Error?

How to Fix SQL Server Does Not Exist or Access Denied Error?

Neeraj Kumar
Published By Neeraj Kumar
Debasish Pramanik
Approved By Debasish Pramanik
Published On
Last Updated

SQL Server does not exist or access denied means the client cannot find the instance or the login cannot enter. Test with a UDL file first. Then check the connection string, the services, the login permissions and the client driver. Recovery software exports tables from the MDF file when access remains denied.

Your application shows SQL Server does not exist or access denied and the connection never opens. Two problems share one message. Either the client cannot find the instance or the login has no right to enter.

Most guides jump to the firewall or to DBCC CHECKDB. Few separate the name problem from the permission problem.

This guide explains six ways to fix SQL Server does not exist or access denied and how to export your data when access remains denied.

Microsoft lists the checks in its connectivity errors checklist.

Which Problem Does the Message Mean?

Test the connection outside your application first. Then match the result in this table:

SignCauseFix
The UDL test fails with a network errorName, protocol or port problemMethods #2 and #3
The UDL test connects and the application failsWrong connection string or old driverMethods #2 and #5
Other logins connect and yours failsMissing login permissionMethod #4
Other PCs connect and one PC failsClient alias, driver or firewall on that PCMethod #5

UDL tests with the tcp: prefix, the full server name and the port avoid common SQL Server Browser issues according to Microsoft.

What Should You Collect First?

Four items shorten the search:

  1. Copy the exact error text and note whether the failure is constant or intermittent.
  2. Find the connection string in the application. Microsoft names Web.config for ASP.NET applications.
  3. Open the SQL Server error log of the instance.
  4. Check the Windows event logs of the client and the server.

6 Ways to Fix SQL Server Does Not Exist or Access Denied Error

Windows and SQL Server tools handle Methods #1 to #5 and software handles Method #6:

MethodBest ForLimit
Test With a UDL FileFinding the failing layerNeeds the right provider
Fix the Connection StringApplication only failuresNeeds access to the config file
Check Services and ProtocolsName and port problemsNeeds a local connection
Fix Login PermissionsAccess denied for one loginNeeds an administrator login
Update the Client DriverOne failing PCNeeds administrator rights on the client
Export From the MDF FileData while access remains deniedTrial exports are capped

Method #1: Test the Connection With a UDL File (Free)

UDL files test the connection without your application and show which layer fails. Six steps create it:

  1. Open File Explorer Options, select the View tab and clear Hide extensions for known file types.
  2. Create a text file named sqlconn.txt in C:\temp.
  3. Rename the file to sqlconn.udl and select Yes at the extension warning.
  4. Double click the UDL file and select Microsoft OLE DB Driver for SQL Server on the Provider tab. Click Next.
  5. Type the server in Select or enter a server name, for example tcp:SQLHOST01,1433.
  6. Enter the login your application uses and click Test Connection.

Note: A failed test needs a change of protocol. Try tcp:, np: and lpc: one after another. Use the IP address alone and remove the port to test SQL Server Browser.

Passing with lpc: and failing with tcp: means TCP is disabled in Configuration Manager.

Applications with 32 bit providers on 64 bit Windows need the 32 bit dialog. Open %windir%\SysWoW64\cmd.exe and type START C:\TEMP\SQLCONN.UDL.

Method #2: Fix the Connection String (Free)

Passed UDL tests and failing applications point to the string. Five steps compare them:

  1. Open the UDL file in Notepad to see the saved string.
  2. Open the configuration file of your application.
  3. Compare the server name, the instance name and the port in both strings.
  4. Replace the application value with the working one.
  5. Restart the application.

Note: Name patterns for default instances, named instances and custom ports sit in Could Not Open a Connection to SQL Server Error 40.

Method #3: Check the Services and Protocols (Free)

Check the instance before the client. Four checks follow:

  1. Search the error log for the ready message:
Get-ChildItem -Path "c:\program files\microsoft sql server\mssql*" -Recurse -Include Errorlog | Select-String "SQL Server is now ready for client connections."
  1. Search the same logs for the listening port:
Get-ChildItem -Path "c:\program files\microsoft sql server\mssql*" -Recurse -Include Errorlog | Select-String "Server is listening on"
  1. Test the name and the IP address with ping -a <server name> and ping -a <IP address>.
  2. Start SQL Server Browser for a named instance in Configuration Manager.

Note: No ready message means the instance is stopped. How to Fix SQL Server Instance Not Starting explains the fixes.

Method #4: Fix the Login and Database Permissions (Free)

Access denied points to the login. Microsoft requires CONNECT SQL on the server and CONNECT on the database. Four steps check and fix both:

  1. Connect to the instance with an administrator login in SSMS.
  2. Check the login:
SELECT pr.name, pr.is_disabled, pr.default_database_name,
       pe.permission_name, pe.state_desc
FROM sys.server_principals AS pr
LEFT OUTER JOIN sys.server_permissions AS pe
  ON pr.principal_id = pe.grantee_principal_id
WHERE pr.name = 'CONTOSO\JaneK';
  1. Grant the server permission and correct the default database:
GRANT CONNECT SQL TO [CONTOSO\JaneK];
ALTER LOGIN [CONTOSO\JaneK] WITH DEFAULT_DATABASE = [mydb];
  1. Grant the database permission to the mapped user:
USE mydb;
GRANT CONNECT TO [JaneK];

Note: Replace the sample names with your own. sp_helplogins 'CONTOSO\JaneK' shows the mapping between the login and the database user.

Method #5: Update the Client Driver (Free)

Compare the failing client with a working one. Four steps narrow the cause:

  1. Connect with the same login from another PC.
  2. Check the Windows event logs of the failing PC.
  3. Update the network driver when the check shows an old version.
  4. Select Microsoft OLE DB Driver for SQL Server in the application.

Note: Microsoft calls that driver the latest one with TLS 1.2 and 1.3 support. Legacy SQLOLEDB ships with Windows and fails when the instance requires newer TLS channel bindings. Remove wrong aliases with the steps in Method #5 of the error 40 guide.

Method #6: Export Your Tables Without a Login Using EmailDoctor (Trial Limit Applies)

Permission fixes need an administrator login and you do not always have one. EmailDoctor SQL Database Recovery processes the MDF file copy on your PC and needs no SQL login. Recovered objects include tables, views, functions and stored procedures.

Trial exports cap every table at 25 records and the other objects at 5.

Scan the Copied File

Stop the SQL Server service before you copy the file because Windows refuses to copy an open database file. Six steps scan the copy:

  1. Copy the MDF file into a folder on your PC.
  2. Start the recovery software and wait for the home screen. Recovery software start screen
  3. Click Open and select the copied file. Open button MDF file selection window
  4. Choose the scan mode. Quick Scan fits a healthy file. Scan mode choices
  5. Keep Auto detect or select the SQL Server version. SQL Server version choices
  6. Wait for the scan report. Scan report

Export the Tables

Three steps export the data:

  1. Select a table to preview the recovered records. Recovered records preview
  2. Click Export. Export button
  3. Select CSV as the export type and a destination folder. Export type choices

Which Problems Remain After the Fixes?

Five patterns explain the failures that remain:

ProblemReasonFix
The UDL test passes and the application failsWrong connection string or old providerCopy the working UDL string into the application
The test passes with lpc: and fails with tcp:TCP is disabledEnable TCP in Configuration Manager
Login failed after the connection opensMissing CONNECT SQL permission or wrong default databaseApply Method #4
A 32 bit application fails and the UDL passesThe UDL used a 64 bit providerTest from the 32 bit Command Prompt
Connections close at randomTLS or cipher suite mismatchUpdate the client driver and check TLS settings

Frequently Asked Questions

Why Does the Error Appear Only in My Application?

Your server works and your application sends a different string. Compare it with the UDL string that passed.

Does DBCC CHECKDB Fix This Error?

No. DBCC CHECKDB checks database integrity and does not change network paths or login rights. Many guides list it for this error and the cause is almost never a damaged file.

Which Provider Should I Select in the UDL File?

Select the provider your application uses. Microsoft recommends the OLE DB Driver for SQL Server for newer versions and describes SQLOLEDB as the legacy provider.

Why Does the UDL Test Pass but My 32 Bit Application Fails?

Default UDL dialogs use 64 bit providers on 64 bit Windows. Open the 32 bit Command Prompt and start the UDL file from it.

Does the Message Mean the Database Does Not Exist?

No. SQL Server names the instance and not a database in this message. Check the default database of the login when access is denied.

What Does Cannot Generate SSPI Context Mean?

Microsoft links the message to a missing service principal name. Verify and fix the SPN of the SQL Server service account.

Why Does the Connection Close After It Opens?

Microsoft links forcibly closed connections to a Diffie-Hellman cipher suite warning in the SQLCHECK output. Update the client driver and review the TLS settings.

Can I Test the Recovery Software Before I Buy?

Yes. Trial exports cap every table at 25 records and the other objects at 5 until you buy a license.

Author’s Verdict

Test the connection with a UDL file before any change. UDL results show whether the name, the login or the application string fails.

Fix the permission with the lowest right that works and keep the connection string in one place.

Use recovery software when the data is due and access remains denied.

  • Clients get this message when they cannot find the instance or the login cannot enter.
  • UDL tests, connection strings, services, login permissions and client drivers find the cause.
  • Recovery software exports tables from the copied MDF file.
  Neeraj Kumar

By Neeraj Kumar

Neeraj Kumar is a Principal Technical Architect at EmailDoctor with 19+ years of experience in email migration, cloud migration, data recovery and digital forensics. He guides enterprise teams through Exchange, Office 365 and Google Workspace projects and shares what works as an EmailDoctor writer. Every method in his posts is tested on Windows and Mac before it goes live.