# Windows – Killing remotely hanging RDP session

Use query session and reset session to identify and clear a hung Remote Desktop session on a Windows server when normal sign-in is blocked.

blog

03 Mar 2015 pl

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.

```powershell
net use \\servername_or_IP /user:username password
```

Now query the sessions:

```powershell
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`:

```powershell
reset session ID /server:servername_or_IP
```

For example:

```powershell
reset session 2 /server:TEST2003
```

## Example output

```powershell
query session /server:TEST2003
```

```powershell
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.

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Windows – zdalne zakończenie zawieszonej sesji RDP](/blog/windows-zdalne-zakonczenie-zawieszonej-sesji-rdp/)
- [How to contribute a post to evotec.xyz](/blog/how-to-contribute-to-evotec-blog/)
- [Happy New Year!](/blog/happy-new-year/)

<!-- PowerForge markdown artifact sha256:899C6864EE8D4F1120850B3B802564F1EC49FBD6DD4894E3F7B8D7F7891CCBFB -->
