You're at the office, coffee in hand, and you try to RDP into your work machine from home. Instead of the login screen, you get that ugly dialog: ERROR_CTX_SESSION_IN_USE (0X00001B96) – The user %s\\%s is currently logged on to this computer. The machine is locked, but the session never ended. I've seen this on Windows 10, Server 2016, and Server 2019 – it's a classic.
Why this happens
When you disconnect from a Remote Desktop session without logging off (just closing the window or losing connection), Windows keeps the session alive – it goes to the lock screen. That session holds a lock on the user profile and resources. When you try to connect again, Windows sees that user as already logged on and refuses to start a second session, throwing 0X00001B96.
This is by design, but it's annoying because you can't just "X" out of that error and get in – you need to kick the old session. The real fix is to force that session to disconnect or log off.
The fix
You have two paths: use the command line (fastest) or use Remote Desktop Services Manager if you have admin rights on the target machine. I'll show you the command-line route first because it works everywhere.
Step 1: Open an elevated command prompt
On the machine that's rejecting your connection, open Command Prompt as Administrator. Press Win, type cmd, right-click it, and choose Run as administrator.
Step 2: List active sessions
Run this command to see all sessions and their IDs:
query session
You'll see output like this:
SESSIONNAME USERNAME ID STATE TYPE DEVICE
console admin 1 Active Console
rdp-tcp#3 admin 2 Disc RDP
rdp-tcp 65536 Listen
Look for the session with your username that's in Disc (disconnected) state. Note the ID number – that's what you'll target.
Step 3: Disconnect or reset that session
You have two options. If you just need to close the session so you can log in fresh, use tsdiscon – it disconnects but leaves the session in memory:
tsdiscon 2
Replace 2 with the session ID you found. Wait a few seconds, then try your RDP connection again. This usually works because the session becomes disconnected but still holds the user lock – wait, no, actually tsdiscon doesn't release the lock. The error will still appear because the user is still in a disconnected state. The reliable option is reset session, which forces a logoff:
reset session 2
This kills the session – any unsaved work in that session is gone, so use it wisely. But that's the only way to clear the lock. After reset, wait a few seconds for the session to fully terminate, then RDP again. It'll go straight to the login screen.
Step 4: If you're not on the target machine
Maybe you can't get to the console because it's remote. You can use the same commands from another machine with RDP admin rights. Open Command Prompt on your current machine, then run:
query session /server:COMPUTERNAME
And then:
reset session 2 /server:COMPUTERNAME
You'll need local admin rights on that target. This works when you're locked out of the target's desktop but still have network access.
What if it still fails?
If reset session gives you an error like "The specified session is not found" – double-check the session ID. Also, sometimes the session is in an Active state on the console (someone is physically at the machine). In that case, you can't reset it without logging them out, which is a policy issue. Check group policy: if you have "Restrict Remote Desktop Services users to a single Remote Desktop Services session" enabled, that's what's causing the block. You can disable it via gpedit.msc under Computer Configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Connections – set it to Disabled to allow multiple sessions. But that's a workaround, not a fix for the immediate lock.
In my experience, reset session works 9 times out of 10. Keep the command in your back pocket – you'll need it again.