I’m hosting this site and many other small sites from a web server at my house over DSL with a static IP address. For the most part, it is just me doing the server administration and tinkering. However, every now and then Brian needs to get on the box to do some configuration of his sites. Unfortunately, lately he has been getting plagued with the “Terminal server has exceeded maximum number of allowed connection” message when he tries to connect with Remote Desktop. Of course, I’m to blame because I typically have a Remote Desktop connection from my desktop at home and from my desktop at work. Since I tend to do little changes here and there between tasks, I usually leave Remote Desktop connected so that I can jump in and out. Especially if I’m making changes to WordPress, I’ll leave the text editor and file explorer open for a couple days in a row.
However, due to our pending release of MyHomePoint and the fact that Brian is carrying the majority of the weight right now, he needs access to the server more and more these days to do releases, testing, etc. And of course, he keeps getting denied access to the server due to my bad habits. I knew there was a limit on the number of connections allowed and I’m sure that there was a way to control the expiration of those sessions. Of course, a quick check on Microsoft’s site found this Knowledge Base article: Error Messages Generated When Logging on with Terminal Services Client. Of course, the description didn’t really give me much more to go on to solve the problem:
Description: The user is attempting to log on to a Terminal Server in Remote Administration mode, but the server has reached its connection limit. Terminal Servers in Remote Administration mode allow a maximum of 2 concurrent sessions, active or disconnected.
After a little more digging and Googling, I ran across a forum thread with some more information and some solutions.
First, if your two primary connections to the server are locked out, you can still access the server console from your command line with the following command:
  1. <br />   
  2. mstsc -v:0.0.0.0 /f -console<br />   

(Of course you would replace 0.0.0.0 with the correct IP address of the server) This will essentially give you a third remote connection to the server. You should probably only use this connection to jump in and kick off existing connections. If bad habits got you into the problem in the first place, the last thing you need is for your contingency connection to be locked as well. You can delete existing connections by going to Start > Control Panel > Administrative Tools > Terminal Services Manager. Once that window opens, expand the This Computer node in the left-hand panel. The next node should be an entry for your server. Click on your server name and notice that the panel on the right-hand side has tabs for Users, Sessions, and Processes. Click on the Users tab and you should see all existing connections. Some of the icons for the connections may be greyed-out to indicate that the session has expired. These are the sessions that are taking up connections unnecessarily. Right-click on the user/session that is no longer needed and select “Log Off” from the bottom of the list. This kills that user/session and frees up the connection. The other options (like Disconect) don’t actually free up the connection.
The second bit of interesting information from the thread was you can configure the settings on terminal server to manage the connections in a variety of ways. You do that through Start > Control Panel > Administrative Tools > Terminal Services Configuration. Select the Connections folder from the left panel. In the right panel you should see the available connection types. Most likely there will be an entry for RDP-Tcp (Microsoft RDP 5.2). Right-click on that entry and select Properties. Select the Sessions tab and you will see a number of options related to sessions. All of my dropdowns were set to Never, which explained why they never timed-out. To solve our problem, I checked the ‘Override user settings‘ option and set ‘End a disconnected session’ and ‘Idle session limit’ to 15 minutes. I left the ‘Active session limit’ at Never since as long as you are actively using the connection, then I don’t really care how long you’ve been on.
I know these settings apply to Windows Server 2003 Standard Edition. They may or may not apply to other versions. I hope the details in this article help someone out!