- Error number
- 10061
- Severity
- 20 (fatal: the connection ends; may indicate a serious problem)
- State
- 0
- Product
- SQL Server client network libraries (SqlClient, ODBC Driver for SQL Server)
- Versions
- Any SQL Server version; raised by the client network library (SqlClient, ODBC, SSMS), not by the Database Engine
- Category
- Connectivity
- Last reviewed
- 23 October 2026
On this page
What it means
Error 10061 means the client reached the machine at that address, but nothing was accepting TCP connections on the port it tried, so the connection was refused.
10061 is the Windows sockets code for "connection refused". The host name resolved and the machine answered, but no program was listening on that port, or a firewall on the host rejected the connection. Nothing reached SQL Server, so its error log has no entry. Read the message as "right machine, wrong door": check that the instance is running, that it listens on TCP, and on which port.
On our lab instance, TCP/IP was disabled (the error log showed only the dedicated admin connection on 127.0.0.1 port 1434), and connecting to port 1433 was refused exactly like a port that nothing uses. The refusal was not instant: the client kept retrying until its login timeout ran out (about 30 seconds), and with a 5-second timeout it reported The wait operation timed out instead, as did .NET Framework SqlClient (error 258). So a timeout message does not rule out a closed port; test the port directly.
Common causes
- TCP/IP is disabled for the instance (the default in Developer and Express editions), so the Database Engine listens on no TCP port for clients.
- The instance listens on a different port than the client uses, for example a named instance on a dynamic port while the client tries 1433.
- The SQL Server service is stopped, so nothing listens on its port.
- A host firewall that rejects (rather than drops) connections to the port.
- The connection string points at the right machine but the wrong instance or an old port number.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
Find the port the instance really listens on
Run on the server through a local connection (shared memory works even when TCP/IP is off).
EXEC sp_readerrorlog 0, 1, N'Server is listening on'; A line such as Server is listening on [ 'any' <ipv4> 1433] gives the port. Only 127.0.0.1 or ::1 on port 1434 means TCP/IP for clients is disabled; that port is the dedicated admin connection, not the instance port.
Check whether TCP/IP is enabled and which port is configured
SELECT registry_key, value_name, value_data
FROM sys.dm_server_registry
WHERE (registry_key LIKE N'%SuperSocketNetLib\Tcp' AND value_name = N'Enabled')
OR registry_key LIKE N'%SuperSocketNetLib\Tcp\IPAll'; Enabled = 0 explains 10061 on every TCP port. Under IPAll, TcpPort is the static port and TcpDynamicPorts the dynamic one.
See how your own connection is connected
SELECT net_transport, local_net_address, local_tcp_port
FROM sys.dm_exec_connections
WHERE session_id = @@SPID; Shared memory means you are local and not using TCP at all, so a working local connection proves nothing about TCP. A TCP connection shows the port that worked.
Test the port from the client
Run in PowerShell on the client machine.
Test-NetConnection sqlhost01 -Port 1433 TcpTestSucceeded : False with PingSucceeded : True or a resolved address points to the listener, the port number or a host firewall.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Connect to the port the instance listens on
Client or network sideUse the port from the error log in the connection string, with the tcp: prefix so the client does not fall back to another protocol. Port 1434 is the SQL Server Browser (UDP) and the dedicated admin connection, not an instance port.
-- sqlcmd -S tcp:sqlhost01,1433 -E -C
-- Server=tcp:sqlhost01,1433;Database=Sales;Integrated Security=true;
Enable TCP/IP for the instance
Changes configurationIn SQL Server Configuration Manager, open SQL Server Network Configuration, Protocols for your instance, and enable TCP/IP. On the IP Addresses tab, under IPAll, set a static TCP Port if clients should not depend on SQL Server Browser. Restart the service.
Caution: The change takes effect only after the SQL Server service restarts, which disconnects every session.
Start the SQL Server service
Changes configurationIf the service is stopped, start it and set it to start automatically.
# PowerShell, elevated, on the server
Start-Service -Name MSSQLSERVER
Set-Service -Name MSSQLSERVER -StartupType Automatic
Allow the port through the host firewall
Changes configurationAllow inbound TCP on the instance port. For named instances on dynamic ports, also allow UDP 1434 for SQL Server Browser.
# PowerShell, elevated, on the server
New-NetFirewallRule -DisplayName 'SQL Server TCP 1433' -Direction Inbound -Protocol TCP -LocalPort 1433 -Action Allow
Examples
TCP/IP disabled on the instance
Reproduced on the lab machine, where the instance has TCP/IP disabled. Port 1433 on the same machine refuses the connection; a local shared-memory connection (sqlcmd -S .) still works, which is why the problem often goes unnoticed until a remote client connects.
-- From a command prompt on the server itself:
-- sqlcmd -S tcp:127.0.0.1,1433 -E -C -l 30
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: No connection could be made because the target machine actively refused it. . Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to tcp:127.0.0.1,1433. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
A wrong port in a .NET connection string
Reproduced with System.Data.SqlClient in PowerShell 7 against a port nothing listens on: SqlException Number 10061, Class 20, State 0, raised after the connect timeout.
-- PowerShell 7:
-- $c = New-Object System.Data.SqlClient.SqlConnection 'Server=127.0.0.1,1;Integrated Security=true;Connect Timeout=60'
-- $c.Open()
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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)
The same refused port with a short login timeout
Reproduced: with a 5-second login timeout the client gave up before reporting the refusal, so the message talks about a timeout. Increase the timeout or test the port with Test-NetConnection before chasing network latency.
-- From a command prompt:
-- sqlcmd -S tcp:127.0.0.1,1 -E -C -l 5
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: The wait operation timed out. . Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to tcp:127.0.0.1,1. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
How to prevent it
Give each instance a static TCP port, record it with the server, and put it in every connection string (tcp:host,port). Enable TCP/IP as part of the server build, because the default in some editions is off and local tools keep working through shared memory.
After patching or rebuilding a server, check the "Server is listening on" lines in the error log and run Test-NetConnection from an application server. Both take seconds and catch a closed port before users do.
Common questions
What is the difference between error 10061 and error 53?
Error 10061 means the machine was reached but the TCP port refused the connection. Error 53 means the client could not open any path to the named server, typically reported by named pipes after the name or the path failed.
Is a refused connection always fast?
Not in our tests. On Windows the client kept retrying a refused local port until its login timeout expired, and with a short timeout it reported a timeout (Windows error 258) instead of 10061. Test the port directly to tell the two apart.
I can connect on the server itself but remote clients get 10061. Why?
Local tools often use shared memory, which works with TCP/IP disabled. Remote clients need TCP. Check the error log for "Server is listening on" lines and enable TCP/IP if they only show the admin connection.
Learn more on CodeWithSQL
Official documentation
- Fix network-related or instance-specific errors in SQL Server (Microsoft Learn)
- Configure a server to listen on a specific TCP port (Microsoft Learn)
- Enable or disable a server network protocol (Microsoft Learn)
Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.