Thursday, August 27, 2009

Manually Killing Terminal Service Connections

Problem: You’re trying to RDP to a remote server and you get the message “The terminal server has exceeded the maximum number of allowed connections.” You need to be able to examine current open sessions and kill unused ones.

Solution: Open a command prompt from an account with admin privileges. Use the ‘query’ command to find out who has sessions open on the target system:

C:\Users\jholmes>query session /server:myserver
 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 console                                     0  Conn    wdcon
 rdp-tcp                                 65536  Listen  rdpwd
                   schambers                 1  Disc    rdpwd
                   schambers                 2  Disc    rdpwd

We can easily see that someone’s hogging up the sole two allowed connections by logging on, then killing the RDP session while still connected. Nervy.

No matter, I can fix that quite easily with the ‘reset’ command:

C:\Users\jholmes>reset session 1 /server:myserver

This kills the session Now I’m able to RDP on to the server without being blocked by someone who wasn’t cleaning up after themselves…

1 comment:

Justin Kohnen said...

Great tip Jim, thanks. I thought I would share another way to kill a remote connection.

You can use the terminal service manager in administrative tools.


Choose Actions > Connect to Computer
Type in myserver
Once you connect (if you have permissions) you can pick that computer. You'll see the open sessions. Then you can right click on one and say "log off".

Same effect as your suggestion, just a different way to do it for those GUI people.

Subscribe (RSS)

The Leadership Journey