How to Disconnect a Remote Desktop Session

Have you ever come across the error message “The terminal server has exceeded the maximum number of allowed connections” while trying to login to a Windows machine as an administrator?

The error message is displayed as Windows only allows two remote terminal services sessions for an administrator. Sometimes the error message is displayed even though there is only a single active session. The other session could be an hanging session that could have been disconnected in an abrupt manner.

If the Windows server is part of domain, just open the Terminal Services Manager to remove the invalid sessions. If the server is not part of a domain, you will need to connect to the machine locally or via telnet or ssh. Once logged in, run the following command to list the sessions:

Do you notice that the session with an ID number of 2 is disconnected ?

We can now proceed to remove that session.

The offending session should now be closed. You can run the query command again to confirm that the session has been closed.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }