0X00001B59

Fixing 0X00001B59: Invalid Session Name in Remote Desktop

Windows Errors Intermediate 👁 3 views 📅 Jun 2, 2026

This error pops up when Remote Desktop cant find the session name you typed. Usually happens after a Windows update or when someone renamed the session.

You're sitting at your desk, trying to remote into a client's server — maybe a Windows Server 2019 box running Terminal Services. You type the session name exactly like you always do, but instead of connecting, you get hit with ERROR_CTX_WINSTATION_NAME_INVALID (0X00001B59). The exact message reads: "The specified session name is invalid." Had a client last month whose entire print queue died because of this — turned out their admin had renamed the default RDP-Tcp session and didn't tell anyone.

This error usually pops up in two scenarios: either you're using mstsc /admin or a terminal server client and the session name you typed doesn't match what's registered in the system, or a Windows update changed how session names are resolved. I've also seen it after someone manually renamed the console session in the registry.

What's Actually Going On

Windows Terminal Services (the old name for Remote Desktop Services) keeps a list of session names — stuff like "RDP-Tcp" or "Console" or custom names you've set up. When you type a session name in your RDP client, Windows tries to match it against that list. If it can't find a match, you get this error. The root cause is almost always a mismatch: you typed "RDP-Tcp" but the session is actually named "RDP-Tcp#0" or someone deleted it entirely.

Another common trigger is a botched registry entry. I've seen this after a Windows 10 22H2 update corrupted the Terminal Server registry key. The fix is straightforward — you just need to clean up the session name list or recreate the default session.

Fix It in 4 Steps

Step 1: Check Current Session Names

Before you can fix a wrong name, you need to know what names actually exist. Open PowerShell as Administrator and run:

query session

This lists all active sessions. You'll see something like:

SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>console           Administrator            1  Active
rdp-tcp                                 2  Listen

Note the exact session name — case matters in some versions. If you don't see your session listed, move to Step 2.

Step 2: Verify the Registry Entry

The session names live in the registry. Open regedit and go to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations

You should see a subkey for each session — at minimum RDP-Tcp and Console. If any of them are missing or corrupted, that's your problem. Common corruption signs: empty keys, missing DriverName value, or a UserConfiguration key with weird data.

If RDP-Tcp is missing entirely, you can recreate it by exporting a working one from another machine — but honestly, it's faster to just rebuild the Terminal Server stack (Step 3).

Step 3: Rebuild the Terminal Server Stack

Skip this if you found a simple typo. But if the registry is busted, the reliable fix is to reinstall the Terminal Services components. On Windows Server, open Server Manager, go to Manage > Remove Roles and Features, uncheck Remote Desktop Services, reboot, then re-add the role. On Windows 10/11 Pro, go to Settings > Apps > Optional Features, find Remote Desktop, remove it, reboot, and re-add it.

This wipes the corrupted session list and recreates the default sessions cleanly. I've used this on at least a dozen machines — never failed.

Step 4: Rename Your Session Back to Default (if you renamed it)

If someone renamed a session (I've seen admins do this to "organize" things), rename it back to the original. In the registry key above, find the session you renamed, double-click the SessionName value, and set it to RDP-Tcp or Console as needed. Then reboot.

Still Getting the Error?

If you've done all that and it still fails, check these:

  • Group Policy: A GPO might be overriding session names. Run gpresult /h gpreport.html and look for Terminal Services policies.
  • Third-party RDP wrappers: Stuff like RDP Wrapper Library can hijack session names. Uninstall it temporarily to test.
  • Corrupt user profile: I've had this happen when the user's profile is messed up. Create a test user and try connecting with that.

One last thing — if you're using mstsc /v:servername /admin, try without the /admin flag. Sometimes that flag forces a console session that doesn't exist anymore.

Was this solution helpful?