blog

Windows – Killing remotely hanging RDP session

Sometimes an RDP session gets stuck in a disconnected or half-dead state and blocks a user from reconnecting. In older environments this often showed up as "all sessions are taken", but the same general cleanup pattern still helps when a Remote Desktop session host keeps a broken session around.

The quickest fix is to list the sessions on the target server, identify the right session ID, and reset only that session.

List the sessions on the remote server

If you need to establish credentials first, you can authenticate before running the session commands. In many domain environments this is unnecessary because your current admin token is already enough.

net use \\servername_or_IP /user:username password

Now query the sessions:

query session /server:servername

That gives you the session name, username, and most importantly the ID you can reset.

Reset the stuck session

Use the ID returned by query session:

reset session ID /server:servername_or_IP

For example:

reset session 2 /server:TEST2003

Example output

query session /server:TEST2003
SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
console                                     0  Conn    wdcon
rdp-tcp                                 65536  Listen  rdpwd
rdp-tcp#32        server-userid1            1  Active  rdpwd
rdp-tcp#33        server-userid2            2  Active  rdpwd

In this example, if session 2 is the broken or abandoned one, that is the ID you would target.

Important warning

reset session is not graceful. Microsoft documents it as a way to delete a malfunctioning or non-responsive session, and it can cause the user to lose unsaved work. That is why it is worth double-checking the username and session ID before you run it.

Current note

As of April 22, 2026, Microsoft still documents both query session and reset session for current Windows Server releases, including Windows Server 2016, 2019, 2022, and 2025. The basic troubleshooting approach from this old post is still valid even though the original examples came from much older server versions.