When this error hits
You're sitting at your Windows 10 laptop. You fire up Remote Desktop Connection, type the IP or hostname of the target machine (likely a Windows 10 Pro or Windows Server 2019/2022 box), and click Connect. The credentials dialog pops up. You enter your username and password. Then, nothing. The window closes. Or you get a generic "Remote Desktop Connection" error box with code 0x4. No details. No retry. Just a dead end.
I've seen this happen most often when the target machine is behind a VPN or a misconfigured firewall, or when the user's credentials are incorrect but Windows doesn't tell you that directly. The error code itself is Microsoft's way of saying "the connection was closed before the session could start." Helpful, right?
Root cause
Error 0x4 is a disconnect before session initialization. The RDP client sends the connection request, the server accepts it, but something prevents the session from fully establishing. The usual suspects:
- Network Level Authentication (NLA) mismatch — The server requires NLA, your client isn't set up for it, or vice versa.
- Credential failure — The user account doesn't have remote access permissions, or the password is wrong. Windows won't always show a login failure; it just closes the connection.
- Firewall or port blocking — Port 3389 is open for the initial handshake, but something (like an antivirus, VPN split tunneling, or corporate proxy) drops the session after the credential exchange.
- Session limit reached — The target machine has hit its max concurrent RDP sessions (typically 1 for Windows 10, 2 for Server).
In my experience, the #1 cause is the NLA issue. The server rejects the handshake because the client doesn't support the authentication level it expects.
Fix it — step by step
Try these in order. Skip the first one if it doesn't apply.
Step 1: Disable Network Level Authentication on the server
If you have access to the target machine (physically or via another admin session), turn off NLA. This is the quickest fix for the mismatch issue.
- On the target machine, go to System Properties (right-click This PC > Properties > Remote Desktop).
- Uncheck "Require devices to use Network Level Authentication to connect".
- Click OK, then try connecting again from the client.
This worked for me on a Windows 10 client connecting to a Windows Server 2019 box behind a VPN. After disabling NLA, the session connected immediately.
Step 2: Verify credentials and permissions
Make sure the user account you're using is a member of the Remote Desktop Users group on the target machine. If it's an admin account, it's in the Administrators group by default, but I've seen cases where domain group policies strip that. Check locally:
net localgroup "Remote Desktop Users"
If your user isn't listed, add it:
net localgroup "Remote Desktop Users" DOMAIN\username /add
Also, if you're using a Microsoft account (like an @outlook.com email), replace the username with the full email — RDP can be picky about that.
Step 3: Check firewall and network
Port 3389 must be reachable from the client to the server. But here's the thing: even if the initial TCP handshake works, something might be dropping the session later. The RDP session uses dynamic ports after the initial setup, but the key is that the session stays alive during the credential exchange. If you're using a VPN, try disabling it temporarily. If you're behind a corporate firewall, ask the network team to check for Deep Packet Inspection that might kill the RDP session after the NLA handshake.
Quick test from the client: open Command Prompt and run:
test-netconnection -port 3389
Or, if you're on an older Windows version:
telnet 3389
If the port is open, the telnet window will stay blank (not a full disconnect). If it closes immediately or says "could not open connection," the port is blocked. Fix the firewall rule on the server or the network.
Step 4: Clear cached credentials
Sometimes the RDP client caches bad credentials from a previous attempt. Clear them:
- Open Credential Manager in Control Panel.
- Click Windows Credentials.
- Look for any entries under Generic Credentials that mention the target machine's name or IP (like
TERMSRV/192.168.1.100). - Remove them all.
- Try connecting again — you'll be prompted for credentials fresh.
Step 5: Check the RDP session limit
If the target machine already has two users logged in (or one user on Windows 10 Home/Pro), a new session will be rejected. On the server, open Task Manager > Users tab and see who's connected. Or, from an admin command prompt:
query user
You can disconnect a stale session with:
logoff
I once spent 30 minutes debugging error 0x4 only to find my colleague was already RDP'd into the same Win 10 box from home.
Still failing? Check these
- Set the RDP client to connect via TCP only — sometimes UDP is being blocked. In the RDP client, go to Advanced > Connect from anywhere > uncheck "Use UDP for Remote Desktop."
- Update the RDP client — the Windows 10 RDP client version 10.0.19041.1 had a known bug with NLA on some Server 2019 builds. Upgrade to the latest via Windows Update.
- Check the target machine's event logs — Look in Event Viewer > Windows Logs > System. Filter by Source: RemoteDesktopServices-RdpCoreTS. Error 0x4 will show up with more detail under Event ID 131 or 230. You'll often see something like "A connection to the remote computer was lost."
- Try connecting from a different client — another laptop, or even a mobile RDP app. If that works, the issue is client-specific (probably a cached credential or NLA mismatch).
Error 0x4 is frustrating because it's vague, but 90% of the time it's either NLA or a credential/permission problem. Start with Step 1, and you'll be back in your remote session in under five minutes.