Troubleshooting Guide: SQL Server Error 4013 — Incorrect TDS Protocol Stream / Missing MARS TDS Header
Why This Error Happens
This error occurs when the Tabular Data Stream (TDS) packets sent by the client do not conform to the structure SQL Server expects when Multiple Active Result Sets (MARS) is enabled on the connection. It is typically caused by a mismatch between the client driver version and the SQL Server 2025 engine, network-level packet corruption or fragmentation (often from misconfigured firewalls, proxies, or load balancers), or an outdated/corrupted client-side network library (such as an old ODBC or OLE DB driver) that does not properly format MARS session headers. In some cases, antivirus or deep packet inspection software intercepting the connection can also strip or alter TDS headers mid-stream.
Step-by-Step Resolution Guide
Step 1: Update and Verify Client Drivers
- Ensure the client application is using the latest Microsoft ODBC Driver or OLE DB Driver compatible with SQL Server 2025.
- On Windows 11 / Windows Server 2025, check installed driver versions via
Control Panel > ODBC Data Sources (64-bit). - Uninstall legacy drivers (e.g., SQL Server Native Client) and replace with the current Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL) or ODBC Driver 18+.
Step 2: Inspect and Reset Network Path
- Disable any proxy, SSL-inspection, or deep packet inspection (DPI) features on firewalls/antivirus that intercept SQL traffic on port 1433.
- Run
netstat -ano | findstr 1433to confirm no unexpected intermediary process is binding to the SQL Server port. - If using a load balancer, confirm it is configured in “TCP pass-through” mode rather than re-packetizing TDS traffic.
Step 3: Validate MARS Configuration on the Connection String
- Confirm the client connection string includes
MultipleActiveResultSets=Trueonly if the application logic actually requires concurrent result sets. - Remove or correct malformed MARS parameters, as inconsistent flags between client and server can trigger header mismatches.
- Example corrected connection string:
Server=myServer;Database=myDB;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;
Step 4: Restart SQL Server Services and Clear Session Cache
- Open
SQL Server Configuration Managerand restart theSQL Server (MSSQLSERVER)service to clear any corrupted session buffers. - Clear client-side connection pooling by restarting the application pool (IIS) or application service that hosts the database client.
Step 5: Check for Network Packet Fragmentation
- Verify the
Network Packet Sizesetting in SQL Server underServer Properties > Connectionsmatches what the network infrastructure (MTU size) supports — default is 4096 bytes. - Run
Test-NetConnection -ComputerName <SQLServerName> -Port 1433on Windows 11/Server 2025 to confirm clean connectivity without timeouts or resets.
Alternative or Verification Steps
- After applying the fixes, reproduce the original query/application action that triggered Error 4013 and confirm no TDS-related errors appear in SQL Server Error Logs (
SQL Server Management Studio > Management > SQL Server Logs). - If the issue persists, capture a network trace using
WiresharkorNetwork Monitorwhile reproducing the error to confirm whether TDS packets are being altered in transit by security middleware, and work with your network team to exclude SQL Server traffic from inspection rules.