How To: Terminate Extraneous RDP Sessions

Usually, my remote access client (Kaseya) is pretty decent at connecting to client machines and servers. However, I also have a couple clients who are still using Server 2003, and Kaseya can’t even when it comes to that. The connection takes far too long to establish. My alternate connection method (VNC) usually performs admirably with its 60-second negotiation limit, but sometimes that doesn’t work either, and the only thing left to do is to remote into another server and RDP over. The problem with that is I’m not the only IT guy here, and people don’t like to properly terminate their RDP sessions. When that happens, you’ll get a message along the lines of “maximum RDP connections exceeded”.

The default number of concurrent sessions is 2, and this can be changed through group/local policy, on the network adapter, and in the admin tools of the server. However, none of that does you much good if you can’t get to the server in the first place. Thankfully, the trusty command line is always there to help. I present to you: session.


The first thing you have to do is supply admin credentials of the server you’re trying to get to. The syntax for this is net use /user:<admin name> \\<server>. You can supply the password on the same line, but I like to have it ask me, to make sure I have the right user selected.

Next, we need to see how many RDP sessions are active. query session /server:<server> will display just that. What we’re interested in are any sessions with the name rdp-tcp#. In the example above there are already 2 sessions active, so it makes sense that the server would be rejecting a 3rd.

In order to close the extra sessions, we have to reset them. To do this, type query session <id> /server:<server>. The ID is listed in the 3rd column when you query the sessions. You can see above that the sessions had an ID of 3 and 34, so I reset both of them, and queried again to show that they were in fact closed. After clearing out the extra sessions, I was able to connect just fine. Happy troubleshooting!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s