Laptop and server connected by a broken cable, representing SQL Server connection troubleshooting

Can’t Connect to SQL Server? Fix Error 26, 40, 53 and 18456 Step by Step

Why SQL Server connections fail and how to fix them layer by layer: services, instance names, TCP/IP, firewall ports, login failure states and certificate errors with newer drivers.

March 3, 2021

The application won’t start in the morning, SSMS won’t connect, or nobody can reach a freshly built server. SQL Server connection errors usually arrive with the same generic message, and that message doesn’t tell you where the problem is. Yet a connection only works when several layers work in order: the service must be running, the client must find the right instance, the network and firewall must allow it, the login must be accepted and, with newer drivers, the encryption certificate must validate.

This guide explains which layer the most common errors (26, 40, 53, 10060 and 18456) point to, and how to fix each one step by step.

SQL Server Emergency Support

Can't your application connect to SQL Server?

Aryasoft's senior DBA team quickly diagnoses connection, authentication and certificate problems and fixes them for good.

Get Support

What the Error Message Is Telling You

The most common message looks like this in SSMS or in application logs:

▤ Messages

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

The beginning of the message is always the same; the clue is the error number in parentheses. Splitting errors into groups tells you where to start:

Error Meaning Layer to check
error: 26 – Error Locating Server/Instance Specified The client couldn’t find the port of the named instance SQL Server Browser, UDP 1434, instance name
error: 40 – Could not open a connection A connection to the server couldn’t be opened Service, TCP/IP protocol, port, firewall
error: 53 – The network path was not found The server name couldn’t be resolved or the machine couldn’t be reached DNS, server name, network access
10060 / 10061, timeout The port is closed or nothing is listening Firewall, port number, service
Login failed (18456) The server was reached, the login was rejected Credentials, login state, authentication mode
Certificate chain not trusted The connection was made, TLS validation failed Certificate, driver version, Encrypt setting

1. Is the SQL Server Service Running?

The first check is the simplest. In SQL Server Configuration Manager or the Windows Services console, confirm that the Database Engine service (SQL Server (MSSQLSERVER) or SQL Server (InstanceName)) is Running. If you use a named instance, the SQL Server Browser service must be running too.

SQL Server Services list in Computer Management showing the state of each service

The same check in PowerShell:

Get-Service -Name 'MSSQL*', 'SQLBrowser' | Select-Object Name, Status, StartType

If the service won’t start, the problem isn’t connectivity but startup, and the reason is in the SQL Server error log and the Windows Application log. Our error log guide shows how to read it.

2. Are You Connecting to the Right Server and Instance?

You connect to a default instance with the server name alone (SERVER) and to a named instance as SERVER\InstanceName. Named instances use a dynamic port by default; the client asks SQL Server Browser for the port over UDP 1434. If Browser is stopped or UDP 1434 is blocked, you get error 26.

There are two permanent fixes: run Browser and allow UDP 1434, or assign the instance a static port and specify it explicitly on the client (SERVER,1450). In production, a static port is usually the better choice because it also makes firewall rules predictable.

The error log shows which IP and port SQL Server is actually listening on:

EXEC sys.xp_readerrorlog 0, 1, N'Server is listening on';

3. Is the TCP/IP Protocol Enabled?

In SQL Server Express and Developer installations, the TCP/IP protocol is disabled by default: you can connect from the server itself but not from another machine. In SQL Server Configuration Manager, enable TCP/IP under SQL Server Network Configuration › Protocols for [instance]. The port setting is on the same screen, under IPAll on the IP Addresses tab. The change takes effect after the service restarts.

4. What Does the “Allow Remote Connections” Box Actually Do?

Many guides recommend ticking Allow remote connections to this server on the Connections page of the server properties.

Allow remote connections to this server option on the Connections page of SSMS Server Properties

Note

This box doesn’t turn remote client connections on or off. The setting behind it, remote access, is a deprecated option that governs remote stored procedure calls between servers. It should stay enabled (the default value 1) for linked servers and log shipping reports. What decides whether clients can connect remotely is the TCP/IP protocol, the port and the firewall.

5. Does the Firewall Allow the Ports?

If the service is running and TCP/IP is enabled but the connection still times out (10060), the firewall is the most likely cause. Allow TCP 1433 for a default instance, the static port for named instances, and UDP 1434 if SQL Server Browser is used. First, test from the client whether the port is reachable:

# From the client: is the port reachable?
Test-NetConnection -ComputerName SERVER -Port 1433

# On the server: inbound rule for the SQL Server port
New-NetFirewallRule -DisplayName 'SQL Server TCP 1433' -Direction Inbound `
    -Protocol TCP -LocalPort 1433 -Action Allow -Profile Domain

TcpTestSucceeded : False means the problem is in the network or the firewall, not in SQL Server. Network devices between the server and the client must allow the same port.

6. Login Failed (18456): The State Number Tells You Why

Error 18456 means the connection reached the server but the login was rejected. For security reasons the message sent to the client is vague; the real reason is the state number in the SQL Server error log:

EXEC sys.xp_readerrorlog 0, 1, N'Login failed';
State Meaning Fix
2, 5 The login doesn’t exist on the server Check the login name or create the login
6 A Windows login was used with SQL authentication Connect with Windows Authentication
7 The login is disabled ALTER LOGIN … ENABLE
8 Wrong password Check the password; watch for account lockout
11, 12 Valid login but no access to the server Check the CONNECT SQL permission and Windows group membership
18 The password must be changed Change the password
38, 40 The login’s default database can’t be opened Check the database name, state and user mapping
58 The server accepts Windows authentication only Switch to Mixed Mode (requires a service restart)

A common cause of 18456 after a migration or restore is a mismatch between the SID of the database user and the server login (an orphaned user). Moving logins to the new server together with their SIDs prevents this from the start.

7. Certificate Errors: Encryption Is Now the Default

ODBC Driver 18, OLE DB Driver 19 and current Microsoft.Data.SqlClient versions encrypt connections by default and validate the server certificate. If the server uses its own self-signed certificate, the connection fails with “The certificate chain was issued by an authority that is not trusted.” A large share of connection errors that appear suddenly after a driver update or a move to SQL Server 2025 come from this; the drivers installed with SQL Server 2025 use this default too.

Warning

Silencing the error with TrustServerCertificate=True works in the short term, but it disables certificate validation and exposes the connection to man-in-the-middle attacks. The permanent fix is to assign the server a certificate your organization trusts, and have clients connect using the name on the certificate.

Linked servers are affected by this change too; we cover the details in our linked server guide.

Connection Troubleshooting Checklist

  1. The Database Engine service and, for named instances, SQL Server Browser are running.
  2. The server name resolves in DNS; the instance name or port is correct.
  3. TCP/IP is enabled; the listening port is confirmed in the error log.
  4. The port is reachable from the client with Test-NetConnection.
  5. The TCP port and, if needed, UDP 1434 are open in the firewall.
  6. For 18456 errors, the state number in the error log has been checked.
  7. With newer drivers, the server certificate comes from a trusted authority.

If none of this helps and the server isn’t responding, connect as a sysadmin through the Dedicated Admin Connection (DAC) to see what’s happening inside the server.

It means a connection couldn’t be opened over Named Pipes or TCP. Usually the service isn’t running, the TCP/IP protocol is disabled, the port is wrong or a firewall is blocking the connection.
Error 26 means the client couldn’t find the port of a named instance. Start the SQL Server Browser service and allow UDP 1434, or assign the instance a static port and connect with SERVER,PORT.
The connection reached the server but the login was rejected. The state number in the SQL Server error log gives the reason: wrong password (8), disabled login (7), unavailable default database (38) or a server that accepts Windows authentication only (58).
No. That box is the old remote access setting, which governs remote stored procedure calls between servers. Client connections need the TCP/IP protocol enabled and the port allowed through the firewall.
Newer drivers encrypt connections by default and validate the certificate. The permanent fix is a trusted certificate on the server. TrustServerCertificate=True is only a temporary workaround and weakens security.

SQL Server Emergency Support

Fix connection problems layer by layer, not by guesswork

Aryasoft’s senior DBA team checks the service, network, authentication and certificate layers in order, fixes the problem for good and documents the configuration so it doesn’t come back.

4.7/5