DEV Community

AdminPackStudio
AdminPackStudio

Posted on

RDP An Internal Error Has Occurred (0x4 / 0x0): A Read-First Listener, Certificate, and Security Layer Triage

Helpdesk: "Since Saturday's patch window, nobody can RDP to APP03 (Windows Server 2022). mstsc shows 'An internal error has occurred.' and under Show details it says 'Error code: 0x4, Extended error code: 0x0'. Sometimes it fails before the password prompt, sometimes right after. APP04 (Server 2019) did the same thing last month. A forum post says to push SecurityLayer and UserAuthentication = 0 to every server by GPO, and another one says to rename the MachineKeys folder. Can we do that?"

Not yet. "An internal error has occurred" isn't a diagnosis. It's the Remote Desktop client telling you the connection fell apart somewhere between the TCP connect and the session, without saying where. Microsoft's own article for this message says "The error occurs before or after entering credentials on the Remote Desktop connection application." and "The issue usually occurs when the source and destination machines negotiate the security protocols, ciphers, or other encryption configurations." So the useful questions are on the target: is the RDP-Tcp listener up, does Remote Desktop Services own port 3389, which certificate is the listener using and can Windows read its private key, and what Security Layer, NLA, and encryption level are in force, from which policy. Microsoft does have an isolation test that sets SecurityLayer and UserAuthentication to 0 on the affected machine, but it's a test on one box, and the same article then says "At the end of the troubleshooting session, configure these settings to the recommended values by using the following commands:". Pushing 0 to every server by GPO turns a one-box test into an estate-wide downgrade. Work through it as a chain: which client, which target, which account, when, and since what change? → what do the target's Remote Desktop and System logs say at that minute? → is it the network or the server (the localhost test)? → is the RDP-Tcp listener up, and does TermService own 3389? → which certificate is bound, and can it be re-created? → are the MachineKeys and RDP key permissions intact? → what Security Layer, NLA, and encryption level apply, and from where? → has a cipher suite or SCHANNEL change broken the TLS side? → is it client-side (UDP, audio, the name used)? → change one link → prove it from the same client. qwinsta, netstat and tasklist /svc, Get-NetTCPConnection, Get-Service, Get-WinEvent, Get-ItemProperty on the RDP-Tcp and policy keys, Win32_TSGeneralSetting through Get-CimInstance, the Remote Desktop certificate store, Get-Acl on MachineKeys, and Test-NetConnection are the sources for that chain. Disable NLA and the TLS security layer everywhere and you've made every server easier to attack for a fault that is often one certificate or one port on one server (our reading).

If the connection goes through an RD Gateway, RD Gateway Not Working covers the gateway's certificate, port, and CAP/RAP side first. If the client message or the target's logs mention licensing instead, Remote Desktop Licensing Mode Is Not Configured covers that. This post covers "a direct Remote Desktop (mstsc or Windows App) connection to a Windows Server 2016, 2019, 2022, or 2025 machine (or a Windows 10 or 11 PC) that fails with An internal error has occurred, often with error code 0x4 and extended error code 0x0, before or after the credential prompt, often after patching, a certificate change, a hardening baseline, a cipher suite policy, or a new agent, and you need a read-first path before you turn off NLA, set the security layer to RDP everywhere, rename MachineKeys, or rebuild the server."

TL;DR

  • Find out where it breaks before you change anything. Microsoft's first test is mstsc to localhost from the server's console: "If the error persists, the problem is with the server." If it works locally, it's the network or the client (Steps 3 and 8).
  • The listener and the port come first. Microsoft: "If the list includes rdp-tcp with a status of Listen, the RDP listener is working." Then make sure the PID that owns 3389 is TermService (Step 4).
  • The certificate is where many server-side cases end (our reading). Read Win32_TSGeneralSetting for SSLCertificateSHA1Hash and its type, then the Remote Desktop store. Microsoft's article lists the services "needed to generate the certificate" and the MachineKeys permissions (Step 5).
  • Security Layer and NLA have policy sources. PolicySourceSecurityLayer tells you whether the value comes from the server, Group Policy, or the default. Microsoft: "Policies override default configurations and should be configured with gpedit.msc (locally) or gpmc.msc (domain level)." (Step 6).
  • Microsoft's 0-and-back test is a test. It sets SecurityLayer and UserAuthentication to 0 on one machine, then back to 2 and 1. If that connects, the cause is the certificate or the protocol negotiation, and you keep reading (Steps 6, 7, and 9).
  • A one-minute hang, then success on retry, is its own pattern. Microsoft ties it to opening audio and says "After around one minute, the connection succeeds because the remote machine resets the connection." (Step 8).

Where in the chain did it break?

Step What should be true Typical symptom when it breaks
1. Symptom captured Which client, target, account, path (direct, VPN, gateway), the exact dialog text and codes, and the time "RDP is broken on APP03" with no client named, no time, and no codes
2. Logs read The target's Remote Desktop logs and System log are read for the failing minute Settings changed without anyone looking at what the server logged when the client gave up
3. Network vs server The localhost test and a port test from the client's network are done Firewalls and VPNs chased for a server whose own console can't RDP to itself
4. Listener and port rdp-tcp is in Listen, TermService owns TCP 3389 (or the configured port), and the services are running Another app or agent bound to 3389 after an install, or the listener disabled by a key or a policy
5. Certificate The listener's certificate exists, matches the configured thumbprint, and its private key is readable A deleted, expired, or replaced certificate, a thumbprint that points to nothing, or a self-signed certificate that can't be re-created
6. Security Layer, NLA, encryption The values in force and their source (server, policy, default) are known and consistent A baseline set SSL plus a certificate the server doesn't have, or an encryption level that doesn't fit the security layer
7. TLS and cipher policy The server's SCHANNEL and cipher suite settings leave something the client can use A cipher suite order policy or a copied SCHANNEL key removed what RDP's TLS handshake needed
8. Client side Other clients work or don't, UDP is allowed or turned off, and the name resolves to the right address One laptop's policy or UDP path blamed on the server, or a hang mistaken for a server fault
9. Change One link fixed on the one machine that needs it, with a backup and a revert NLA off, security layer set to RDP, MachineKeys renamed, and the SCHANNEL key replaced on every server at once
10. Proof The same client and account connect, the logs are clean, and it survives a reboot and a policy refresh Works until the next Group Policy refresh writes the old value back

Step 1: Capture the symptom (read-only)

Write these on the ticket first:

Fact Why it matters
The exact dialog text and the codes under Show details "An internal error has occurred" with an error code, an extended error code, and a timestamp; copy all three. Microsoft's pages we fetched don't decode error code 0x4 for this dialog (our reading of what we found)
Before or after the credential prompt Before usually points at the listener, the port, or the TLS and certificate side; after the prompt can still be the certificate, NLA, or the session itself (our reading)
The client, its OS, and the client app mstsc on Windows 10 or 11, Windows App, an older client on a jump box, or a third-party tool
The target, its OS, and its role A standalone server, a session host in a deployment, a Connection Broker, a domain controller, or an Azure VM
The path Direct on the LAN, over VPN, through an RD Gateway, through a load balancer, or by a different name or port
One client or every client Every client failing points at the target; one failing points at that client, its network, or its policy
The time from the dialog It's the anchor for every log read in Step 2
What changed Patching, a new certificate or template, a hardening baseline, a cipher suite policy, a new agent or app on the server, a restore, a clone, or a sysprep

Then branch on what you see:

What you see What it usually means (our reading unless noted) Start at
Every client fails, and mstsc to localhost on the console fails too Microsoft: "If the error persists, the problem is with the server." Steps 4 to 7
Every client fails, but localhost works The network path, a firewall, or something between the client and the server Step 3
One client fails, others work That client's policy, its UDP path, the name it uses, or its own TLS settings Step 8
It hangs for up to a minute, then fails, and the next try works Microsoft's audio note: "the cause might be the capacity to open the audio to retrieve settings." Step 8
It started right after an app or agent was installed on the server A port conflict on 3389 Step 4
It started after a certificate change, a new template, or a clone The listener points at a certificate that's gone or unreadable Step 5
It started after a hardening baseline or a cipher suite policy The security layer, encryption level, or cipher list changed under RDP Steps 6 and 7
Schannel errors in the System log at the same minute The TLS handshake behind the RDP security layer is failing; read the alert number Step 7
The connection goes through an RD Gateway Start at the gateway The RD Gateway post linked above
It's an Azure VM and you have no console Microsoft's Azure article covers the same causes through Serial Console or an offline repair Steps 4 to 7, then that article

Step 2: Read the target's logs at the failing minute (read-only)

The client dialog is the least specific thing in the chain. The target usually wrote something at the same minute. First list which Remote Desktop logs exist on that build, then read them for a window around the time from the dialog:

# Read-only: the Remote Desktop related logs on this server and how many records each holds
Get-WinEvent -ListLog '*TerminalServices*', '*RemoteDesktopServices*' |
  Select-Object -Property LogName, RecordCount, IsEnabled |
  Format-Table -AutoSize

# Read-only: everything those logs wrote in a 10-minute window around the failure
$failTime = Get-Date -Date '2026-10-19 08:42'
Get-WinEvent -FilterHashtable @{ LogName='*TerminalServices*', '*RemoteDesktopServices*'; StartTime=$failTime.AddMinutes(-5); EndTime=$failTime.AddMinutes(5) } -ErrorAction SilentlyContinue |
  Select-Object -Property TimeCreated, LogName, Id, LevelDisplayName, Message |
  Format-Table -AutoSize -Wrap

# Read-only: the System log for the same window, from the providers that matter here
Get-WinEvent -FilterHashtable @{ LogName='System'; ProviderName='TermDD', 'TermService', 'Schannel', 'Service Control Manager'; StartTime=$failTime.AddMinutes(-5); EndTime=$failTime.AddMinutes(5) } -ErrorAction SilentlyContinue |
  Select-Object -Property TimeCreated, ProviderName, Id, Message |
  Format-Table -AutoSize -Wrap
Enter fullscreen mode Exit fullscreen mode

Get-WinEvent accepts wildcards there: Microsoft's reference says "Wildcard characters are valid only in the values associated with the LogName and ProviderName keys." The dialog's timestamp may be in UTC; convert it before you build the window (our reading). Then match what you find:

What you find (Microsoft's text where quoted) What it tells you (our reading unless noted) Go to
TermDD Event 50: "The RDP protocol component X.224 detected an error in the protocol stream and has disconnected the client." Microsoft lists it on its Remote Desktop disconnected errors page next to the "Because of a security error" messages Steps 5 and 6
Service Control Manager Event 7022: "The Remote Desktop Services service hung on starting." TermService isn't running, so nothing is really listening Step 4
Service Control Manager errors for CertPropSvc, KeyIso, CryptSvc, or SessionEnv Microsoft: "If any of the preceding services fails to start, check if there's a problem with its dependencies on system event logs from the Service Control Manager source." Step 5
Schannel 36887, 36888, or 36874 at the same minute The TLS handshake behind the RDP security layer failed; the alert number in the message is the reason Step 7
Licensing events from TermService or TermServLicensing It's a licensing problem, not this one The licensing post linked above
The Remote Desktop logs show the client's connection arriving and then nothing useful The connection reached the listener; the break is in the security exchange or the session (Steps 5 to 7) Steps 5 to 7
Nothing at all from that client in the window The connection never reached this server's listener: the network, the name, or the port Steps 3 and 4

About the codes. Microsoft's Remote Desktop ActiveX documentation has an extended disconnect reason list that starts with exDiscReasonNoInfo and the text "No additional information is available." for 0, and a disconnect reason list where internal error is a different number, 1032 (0x408). Whether the dialog's extended error code is that same field is our reading, not something the pages we fetched say. Either way, 0x4 and 0x0 don't name a cause; the target's logs and the reads below do.


Step 3: Is it the network or the server? (read-only)

Microsoft's first split is simple. From the target's own console (iLO, iDRAC, the Hyper-V or vSphere console), open Remote Desktop Connection to localhost. Microsoft's article: "If the error no longer occurs, it's related to the network." and "If the error persists, the problem is with the server. Move to the next troubleshooting step." The same test from Microsoft's "can't connect" article comes with a caveat: "The preceding test is only possible on Windows Server machines and might not be available on all occasions (for example, Azure virtual machines)."

# Read-only, on the target's console: does RDP to itself fail the same way?
mstsc /v:localhost

# Read-only, from a machine in the client's network: is the RDP port reachable at all?
Test-NetConnection -ComputerName APP03.contoso.com -Port 3389 -InformationLevel Detailed

# Read-only, on the target: are the built-in Remote Desktop firewall rules enabled, and for which profiles?
Get-NetFirewallRule -DisplayGroup 'Remote Desktop' |
  Select-Object -Property DisplayName, Enabled, Profile, Direction, Action |
  Format-Table -AutoSize
Enter fullscreen mode Exit fullscreen mode

Microsoft on the port test: "In the output list, if TcpTestSucceeded is True, it indicates no connectivity issues." and "If TcpTestSucceeded is False, it indicates connectivity issues." On names: "If the connection fails when using the machine's hostname, try connecting using its IP address." and "If the connection works with the IP address, the issue is likely related to name resolution." Microsoft names the built-in rules "Remote Desktop - User Mode (TCP-In) and Remote Desktop - User Mode (UDP-In)" and says "Make sure that they're enabled to all profiles." On a non-English build the display group name is translated (our reading); Microsoft's firewall reference notes that when the value "is a localizable string", the Group parameter holds an indirect string, so read the group name the local rules actually show.

Result What it means (our reading unless noted) Next
localhost fails the same way The server itself; the network is not the first suspect Step 4
localhost works, TcpTestSucceeded is False A firewall, an NSG, a VPN filter, or routing between the client and the server The firewall and network path first
localhost works, TcpTestSucceeded is True, the error persists The port answers but something about the client, its path, or the name differs Steps 8 and 4
The IP works and the name doesn't Name resolution, a stale record, or a load balancer name DNS for that name
The Remote Desktop rules are disabled or missing a profile The firewall on the target drops the connection on that profile Fix the rule, not the security settings

Step 4: Is the listener up, and does TermService own the port? (read-only)

Microsoft's listener check is qwinsta, and its sample output shows the line you want: rdp-tcp 65536 Listen. Then check which process owns the port. Microsoft: "make sure the Process ID (PID) of TermService matches the one listening on port 3389". TermService runs inside a shared svchost.exe, so Get-Process alone shows only svchost; tasklist /svc shows the service name next to the PID (our reading).

# Read-only: is the RDP-Tcp listener in Listen state?
qwinsta

# Read-only: Microsoft's two commands, PID of TermService and who listens on 3389
tasklist /svc | findstr TermService
netstat -anob | findstr 3389

# Read-only: the same in PowerShell, TCP and UDP
Get-NetTCPConnection -LocalPort 3389 -State Listen | Select-Object -Property LocalAddress, LocalPort, OwningProcess
Get-NetUDPEndpoint -LocalPort 3389 | Select-Object -Property LocalAddress, LocalPort, OwningProcess

# Read-only: the configured port, and whether the listener and RDP itself are switched on
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name PortNumber, fEnableWinStation
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -Name fDenyTSConnections -ErrorAction SilentlyContinue

# Read-only: the services the listener and its certificate depend on
Get-Service -Name TermService, UmRdpService, SessionEnv, CertPropSvc, KeyIso, CryptSvc |
  Select-Object -Property Name, DisplayName, Status, StartType
Enter fullscreen mode Exit fullscreen mode

Microsoft's expected values: "The DWORD value fEnableWinStation has the value data of 1." "The DWORD value fDenyTSConnections has the value data of 0." For the port, "The DWORD value PortNumber has the value 0x00000d3d (3389)." And because both a local and a policy value can exist: "If both policy and default value are configured, make sure both fDenyTSConnections values are set to 0, to avoid possible listener issues." The services Microsoft names for the listener are "Remote Desktop Services (TermService)." and "Remote Desktop Services UserMode Port Redirector (UmRdpService)."

Finding What it means (our reading unless noted) Go to
No rdp-tcp line in Listen The listener isn't running: a disabled key or policy, TermService down, or a damaged RDP-Tcp key The rows below, then Step 9
The PID on 3389 isn't TermService's Another app took the port; Microsoft: "If the PID doesn't match, find what process is listening on port 3389 and stop it." Step 9 (port conflict)
PortNumber isn't 3389 Someone moved the port; Microsoft says clients "should use hostname:port or IPaddress:port as the computer name." Use the right port, or put it back
fEnableWinStation is 0 or fDenyTSConnections is 1 in either place RDP or the listener is switched off by a value or a policy The policy owner first, then Step 9
TermService stopped, or System Event 7022 Nothing is serving RDP; Microsoft's Azure article lists "The TermService service is set to Disabled." and "The TermService service is crashing or not responding." Fix the service before anything else
TCP 3389 is TermService, but no UDP 3389 endpoint UDP transport isn't in play on this server; it's TCP only, which is fine for this error (our reading) Step 5

One more read Microsoft lists in the same article: a cloned or captured image that never finished setup. "Both the DWORD values SystemSetupInProgress and OOBEInProgress are set to 0." under HKLM\SYSTEM\Setup:

# Read-only: is the machine stuck in a sysprep or OOBE state?
Get-ItemProperty -Path 'HKLM:\SYSTEM\Setup' -Name SystemSetupInProgress, OOBEInProgress
Enter fullscreen mode Exit fullscreen mode

Step 5: Which certificate is the listener using, and can Windows read its key? (read-only)

The RDP listener needs a certificate for the TLS security layer: Microsoft's policy reference says "A certificate is needed to authenticate an RD Session Host server when TLS 1.0, 1.1 or 1.2 is used to secure communication between a client and an RD Session Host server during RDP connections." By default that's a self-signed certificate in the computer's Remote Desktop store. Microsoft's listener certificate article: "The certificate for the RDS listener is referenced through the Thumbprint value of that certificate on a SSLCertificateSHA1Hash property." Read what the listener is configured to use, and what is actually in the stores:

# Read-only: the listener's certificate, security layer, NLA, encryption, and where each comes from
Get-CimInstance -Namespace 'root\cimv2\TerminalServices' -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-Tcp'" |
  Select-Object -Property TerminalName, SSLCertificateSHA1Hash, SSLCertificateSHA1HashType, SecurityLayer, PolicySourceSecurityLayer, UserAuthenticationRequired, PolicySourceUserAuthenticationRequired, MinEncryptionLevel, PolicySourceMinEncryptionLevel |
  Format-List

# Read-only: the self-signed RDP certificate store
Get-ChildItem -Path 'Cert:\LocalMachine\Remote Desktop' | Select-Object -Property Subject, NotAfter, Thumbprint, HasPrivateKey

# Read-only: the computer's personal store (where a custom RDP certificate lives)
Get-ChildItem -Path 'Cert:\LocalMachine\My' | Select-Object -Property Subject, NotAfter, Thumbprint, HasPrivateKey

# Read-only: the thumbprint values in the RDP-Tcp key, under both names Microsoft's articles use
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' |
  Select-Object -Property SSLCertificateSHA1Hash, SSLCertificateSHA1HashValue
Enter fullscreen mode Exit fullscreen mode

Microsoft's class reference gives the meaning of SSLCertificateSHA1HashType:

SSLCertificateSHA1HashType Microsoft's meaning What to check (our reading unless noted)
0 Not valid The configured thumbprint doesn't resolve to a usable certificate; compare it to both stores
1 Default self-signed The Remote Desktop store should hold it, unexpired, with HasPrivateKey True
2 Default group policy enforced The Server authentication certificate template policy picked it; Microsoft: "Only certificates created by using the specified certificate template will be considered when a certificate to authenticate the RD Session Host server is automatically selected."
3 Custom Someone bound a certificate from My; check it's still there, unexpired, and readable by NETWORK SERVICE

Then the findings that matter:

Finding What it means (our reading unless noted) Go to
The thumbprint in Win32_TSGeneralSetting isn't in either store The listener points at a certificate that was deleted, renewed, or never imported Step 9 (rebind or re-create)
SSLCertificateSHA1HashValue exists and doesn't match the certificate's thumbprint Microsoft: "If they don't match, delete the SSLCertificateSHA1HashValue value, restart the system, and test again." and "Don't apply this step if the server has the Remote Desktop Connection Broker role installed." Step 9
The Remote Desktop store is empty or the certificate is expired The self-signed certificate wasn't renewed or re-created The services and permissions below
A custom certificate with HasPrivateKey True, but RDP still fails NETWORK SERVICE may not be able to read the key; Microsoft: "The Remote Desktop Host Services runs under the NETWORK SERVICE account." The key permission below, then Step 9
SSLCertificateSHA1HashType is 2 and the certificate keeps changing Group Policy and autoenrollment own it; fix the template, not the server The certificate template owner

Two Microsoft articles name the registry value differently: the listener certificate article uses SSLCertificateSHA1Hash ("Value type: REG_BINARY"), and the internal error article checks "SSLCertificateSHA1HashValue". The Get-ItemProperty read above shows whichever exists; read the WMI value as the one the listener uses (our reading).

If the self-signed certificate isn't being re-created, Microsoft lists four services "needed to generate the certificate": "The certificate propagation service (CertPropSvc)", "The CNG key isolation service (KeyIso)", "The cryptographic services (CryptSvc)", and "The Remote Desktop Configuration service (SessionEnv)" (the Get-Service read in Step 4). It also lists two registry values to confirm: "The SelfSignedCertStore value name has the Remote Desktop value data." under the WinStations key, and "The ProgramData value name has the %SystemDrive%\ProgramData value data." under ProfileList.

# Read-only: the two values Microsoft's article checks for self-signed certificate renewal
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations' -Name SelfSignedCertStore
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' -Name ProgramData

# Read-only: who owns MachineKeys and what the ACL is
Get-Acl -Path 'C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys' | Format-List

# Read-only: the RDP machine key Microsoft's article names, and its ACL
Get-Acl -Path 'C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys\f686aace6942fb7f7ceb231212eef4a4*' | Format-List

# Read-only: a full text snapshot of the folder ACLs (Microsoft's "before" form; writes a file only)
# Microsoft's script creates the folder first with: md c:\temp
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c > C:\temp\BeforeScript_permissions.txt
Enter fullscreen mode Exit fullscreen mode

What Microsoft's Windows Server article expects on the folder: "Make sure that only the following permissions are configured:" with Builtin\Administrators Full control and Everyone Read, Write. For the RDP key whose name starts with f686aace6942fb7f7ceb231212eef4a4, the same article lists Network service Allow Read and System Allow Full control. Microsoft's Azure article resets the folder with a different set (System Full, NETWORK SERVICE Read, Administrators Full), so compare with a working server of the same build before you decide the ACL is wrong (our reading).

Finding What it means (our reading unless noted) Go to
One of the four services is stopped or fails to start The certificate can't be generated; Microsoft points to the Service Control Manager events for its dependencies That service first
SelfSignedCertStore or ProgramData doesn't match Microsoft's value The self-signed path or the key location is off Step 9 (restore the value)
The folder ACL differs from a working server of the same build A hardening script or a cleanup tool changed it Step 9 (Microsoft's reset, with the before and after files)
The f686aace... key has a different owner or no NETWORK SERVICE Read The RDP service can't open its own key Step 9
ACLs match a working server and the certificate looks fine The certificate isn't the break; go to the security layer Step 6

Step 6: What Security Layer, NLA, and encryption level are in force, and from where? (read-only)

Microsoft's internal error article lists three values to check on the RDP-Tcp key: SSLCertificateSHA1HashValue (Step 5), "Make sure the fAllowSecProtocolNegotiation value is set to 1." and "Make sure the MinEncryptionLevel value is set to 3." Read them with SecurityLayer and UserAuthentication, then read the policy key, because a policy value wins:

# Read-only: the listener's local values
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' |
  Select-Object -Property SecurityLayer, UserAuthentication, MinEncryptionLevel, fAllowSecProtocolNegotiation

# Read-only: the policy values (absent means not set by policy)
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' -ErrorAction SilentlyContinue |
  Select-Object -Property SecurityLayer, UserAuthentication, fDenyTSConnections

# Read-only: which GPO set them (computer scope)
gpresult /scope computer /r
Enter fullscreen mode Exit fullscreen mode

The PolicySource* properties from the Step 5 read answer the same question from the listener's side: Microsoft's class reference says each one "Indicates whether the SecurityLayer property is configured by the server, by group policy, or by default." with 0 Server, 1 Group policy, 2 Default. If it says Group policy, a local change won't stick; change the GPO (our reading).

What the values mean, from Microsoft's policy and class references:

Setting Microsoft's description (excerpt) What it means for this error (our reading unless noted)
Security Layer: SSL "The SSL method requires the use of TLS 1.0 to authenticate the RD Session Host server. If TLS isn't supported, the connection fails. This is the recommended setting for this policy." With SSL forced, a missing or unreadable certificate (Step 5) or a broken TLS side (Step 7) fails the connection
Security Layer: Negotiate "The Negotiate method enforces the most secure method that's supported by the client." TLS when the client supports it; otherwise Microsoft: "If TLS isn't supported, native Remote Desktop Protocol (RDP) encryption is used to secure communications, but the RD Session Host server isn't authenticated."
Security Layer: RDP "The RDP method uses native RDP encryption to secure communications between the client and RD Session Host server. If you select this setting, the RD Session Host server isn't authenticated." Microsoft: "Native RDP encryption (as opposed to SSL encryption) isn't recommended." Not a fix to keep
NLA (UserAuthentication 1) "If you enable this policy setting, only client computers that support Network Level Authentication can connect to the RD Session Host server." A client without NLA support fails; Microsoft says to check the client's About box and "look for the phrase Network Level Authentication supported."
NLA off "Disabling this policy setting provides less security because user authentication will occur later in the remote connection process." Only as part of Microsoft's time-boxed test
Encryption level High (3) "Clients that do not support this level of encryption cannot connect." Microsoft's article wants 3 here
Encryption level and SSL together The SSL value "is not compatible with a MinEncryptionLevel value of 1." A baseline that set Low with SSL is a broken combination
FIPS policy Microsoft: the FIPS compliant algorithms setting "overrides the Set client connection encryption level Group Policy setting." A FIPS baseline changes what the listener accepts; check it on a box that broke after one

Microsoft's numbering differs between pages: the SetSecurityLayer method takes "RDP Security Layer" (0), "Negotiate" (1), or "SSL" (2), matching the registry values Microsoft's internal error article sets (0 for the test, 2 for the recommended value), while the property section of the same class page lists the layers as 1 to 3. Read the label as well as the number (our reading).

Finding What it means (our reading unless noted) Go to
fAllowSecProtocolNegotiation isn't 1 The listener can't negotiate the security protocol the way Microsoft's article expects Step 9
MinEncryptionLevel isn't 3, or it's 1 with SSL Microsoft's article wants 3; 1 with SSL is incompatible The policy owner, then Step 9
SecurityLayer 2 (SSL) from policy, certificate problems in Step 5 The policy is fine; the certificate is the break Step 9 for the certificate
UserAuthentication 1 and the failing client is old or third-party The client may not support NLA Update the client, not the server
Values came from a GPO applied at the time it broke The GPO change is the suspect That GPO, tested on one OU

Step 7: Has a cipher suite or SCHANNEL change broken the TLS side? (read-only)

With the security layer at SSL or Negotiate, RDP runs a TLS handshake through Schannel before the session starts, so anything that changes the server's TLS versions or cipher list can surface as this error (our reading). Microsoft's internal error article has a whole section for it, "Security protocol negotiation", and starts with the cipher suite policy: "Check if there's a policy for configuring ciphers. Set the following policy setting to Not configured if it exists:" followed by the SSL Cipher Suite Order setting. Read first:

# Read-only: is a cipher suite order policy in force? (absent means no policy)
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Cryptography\Configuration\SSL\00010002' -Name Functions -ErrorAction SilentlyContinue

# Read-only: the local cipher suite list Microsoft's article tells you to compare
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Cryptography\Configuration\Local\SSL\00010002' -ErrorAction SilentlyContinue

# Read-only: which TLS versions are explicitly set for the client and server roles (empty means OS defaults)
Get-ChildItem -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols' -Recurse |
  ForEach-Object { Get-ItemProperty -Path $_.PSPath } |
  Select-Object -Property PSChildName, PSParentPath, Enabled

# Read-only: OS build, to compare with a working server of the same version
Get-ComputerInfo -Property "*version"
Enter fullscreen mode Exit fullscreen mode

Microsoft's TLS registry reference explains the Protocols layout: "These registry values are configured separately for the protocol client and server roles under the registry subkeys named using the following format:" <SSL/TLS/DTLS> <major version number>.<minor version number><Client\Server>, and it warns that "reducing the set of Enabled (D)TLS and SSL versions could break interoperability with remote peers." If the System log showed Schannel 36887, 36888, or 36874 at the failing minute (Step 2), the alert number in that message is the more specific reason; read it before you change any protocol or suite (our reading).

Finding What it means (our reading unless noted) Go to
A Functions value under the policy key, set by a baseline just before it broke The cipher suite order policy trimmed what RDP's handshake can use; Microsoft's article sets the policy to Not configured as a test The GPO owner, then Step 9
TLS 1.2 Server disabled, or every version disabled on the server The server has no TLS version left that the client offers Step 9 (enable TLS 1.2, not every old version)
The SCHANNEL or local 00010002 values differ from a working server of the same build A hardening tool or a copied key changed them Step 9 (Microsoft's replace step is a last resort)
Schannel alerts point at a certificate (42 to 49) The listener certificate is the break, not the protocol Step 5
Nothing set under Protocols, no cipher policy, no Schannel events The TLS side probably isn't it Step 8

A note on Microsoft's Azure version of this article. Its TLS step says "If TLS 1.1 is disabled on the VM, the connection will fail." and turns TLS 1.0, 1.1, and 1.2 on for the server role, then temporarily stops Group Policy processing so a domain policy can't put the values back. That's a recovery step for a VM you can't otherwise reach, not a baseline. On a domain server you can still reach from the console, read which versions are disabled and why, enable the one the client needs (TLS 1.2), and fix the GPO that disabled it (our reading). After a change, Microsoft's registry reference adds that "an application, or service restart might be required." because services reuse their credential handles.


Step 8: Is it the client side? (read-only)

If Step 3 showed that other clients work, or the failure is a hang that clears on retry, look at the client and the path before the server.

UDP. RDP can use UDP as well as TCP. Microsoft's client policy reference for Turn Off UDP On Client: "If you enable this policy setting, Remote Desktop Protocol traffic will only use the TCP protocol." and "If you disable or don't configure this policy setting, Remote Desktop Protocol traffic will attempt to use both TCP and UDP protocols." On the server side, Select RDP transport protocols offers "Use either UDP or TCP (default)" or "Use only TCP". A path that passes TCP 3389 and drops UDP 3389 is worth testing with TCP only, on one client, before anything else (our reading).

Audio. Microsoft's note on this exact message: "If the connection stops responding for up to one minute before the error appears, and then succeeds on the second attempt, the cause might be the capacity to open the audio to retrieve settings." and "In this case, a blocking call prevents the client from sending the needed information to the server." Microsoft's fix is "To resolve this issue, disable the Windows Audio service on the remote machine and optionally on the source machine if necessary." A smaller first test is an .rdp file with audiomode:i:2 (Microsoft: "Don't play sounds."), so the session doesn't play audio at all; whether that avoids the same call is our reading, not something the article says.

The name. Microsoft's "can't connect" article: "If the connection works with the IP address, the issue is likely related to name resolution." A name that points to an old address, another server, or a load balancer gives you a different listener and a different certificate (our reading).

# Read-only, on the client: is UDP turned off by policy for this client?
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client' -Name fClientDisableUDP -ErrorAction SilentlyContinue

# Read-only, on the target: the Windows Audio service state
Get-Service -DisplayName 'Windows Audio' | Select-Object -Property Name, DisplayName, Status, StartType

# Read-only, on the client: does the name resolve to the address you expect?
Test-NetConnection -ComputerName APP03.contoso.com -Port 3389 -InformationLevel Detailed
Enter fullscreen mode Exit fullscreen mode
Finding What it means (our reading unless noted) Next
Only one client fails, others connect That client: its policy, its network, its RDP client version, or its own TLS settings Compare that client's policy and versions with a working one
It hangs about a minute, then fails, then works on retry Microsoft's audio case The audiomode test, then Microsoft's Windows Audio step on one server
Works with TCP only on that client The UDP path is the problem: a firewall, a VPN, or a NAT device Fix the path or set TCP only by policy for that path
Test-NetConnection resolves the name to an unexpected address Name resolution Fix the record
Every client fails the same way Not the client; go back to Steps 4 to 7 Step 4

Step 9: Change one link (a change)

Back up before any registry change. Microsoft's general troubleshooting article uses this form for the listener key, and the same form works for any key you are about to touch:

# Backup: export the RDP-Tcp listener key before changing it (Microsoft's form)
cmd /c 'reg export "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-tcp" C:\Rdp-tcp-backup.reg'
Enter fullscreen mode Exit fullscreen mode

Then pick the one fix that matches what Steps 2 to 8 found.

The isolation test (one machine, one session). Microsoft's test for "related to the encryption negotiation" sets both values to 0 on the affected machine, then back:

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v SecurityLayer /t REG_DWORD /d 0 /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v UserAuthentication /t REG_DWORD /d 0 /f

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v SecurityLayer /t REG_DWORD /d 2 /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v UserAuthentication /t REG_DWORD /d 1 /f
Enter fullscreen mode Exit fullscreen mode

The first two lines are the test; the last two put Microsoft's "recommended values" back. Microsoft: "If you can connect to the remote machine after running the commands, the issue might be related to either:" the self-signed certificate renewal or the security protocol negotiation. Run the restore lines in the same window, whatever the result. These are policy values, so a domain GPO can overwrite them at the next refresh, and a GPO that already sets them can make the test meaningless (our reading); check the gpresult output from Step 6 first.

Port conflict. Microsoft's order of preference: "Configure the other application or service to use a different port (recommended)." then "Uninstall the other application or service." and last "Configure RDP to use a different port, and then restart the Remote Desktop Services service (not recommended)." Once the other process is off 3389:

# Change: restart Remote Desktop Services (disconnects any RDP sessions on this server)
Restart-Service -Name TermService -Force
Enter fullscreen mode Exit fullscreen mode

Re-create the self-signed certificate. Microsoft's Azure article's PowerShell form deletes the certificate in the Remote Desktop store and restarts the Remote Desktop Configuration service so it's generated again (the Windows Server article does the same with the Certificates snap-in and a Remote Desktop Services restart):

# Change: remove the current RDP self-signed certificate and let SessionEnv create a new one (Microsoft's Azure form)
Import-Module PKI
Set-Location Cert:\LocalMachine
$RdpCertThumbprint = 'Cert:\LocalMachine\Remote Desktop\'+((Get-ChildItem -Path 'Cert:\LocalMachine\Remote Desktop\').thumbprint)
Remove-Item -Path $RdpCertThumbprint
Stop-Service -Name "SessionEnv"
Start-Service -Name "SessionEnv"
Enter fullscreen mode Exit fullscreen mode

Then re-run the Step 5 read. If no new certificate appears, go back to the four services and the MachineKeys permissions; deleting it again won't help (our reading).

Bind a custom certificate. Import it to the computer's Personal store first; Microsoft: "If you don't import the certificate, you'll receive an Invalid Parameter error." Then use Microsoft's PowerShell form in Windows PowerShell 5.1 (the cmdlet's own reference says "Starting in PowerShell 3.0, this cmdlet has been superseded by Get-CimInstance."), and give NETWORK SERVICE Read on the private key through Manage Private Keys:

# Change, in Windows PowerShell 5.1: bind the listener to a certificate by thumbprint (Microsoft's form)
Get-WmiObject -class "Win32_TSGeneralSetting" -Namespace root\cimv2\terminalservices | Set-WmiInstance -Arguments @{SSLCertificateSHA1Hash="THUMBPRINT"}
Enter fullscreen mode Exit fullscreen mode

Microsoft warns about the copied thumbprint: "Remove all spaces from the string. There may be an invisible ACSII character that is also copied." (Microsoft's spelling).

Thumbprint mismatch. Microsoft: "If they don't match, delete the SSLCertificateSHA1HashValue value, restart the system, and test again." Not on a Connection Broker.

MachineKeys ACL. Only after Step 5 showed it differs from a working server of the same build. Microsoft's Azure article resets it with before and after snapshots:

md c:\temp
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c > c:\temp\BeforeScript_permissions.txt
takeown /f "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" /a /r
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c /grant "NT AUTHORITY\System:(F)"
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c /grant "NT AUTHORITY\NETWORK SERVICE:(R)"
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c /grant "BUILTIN\Administrators:(F)"
icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c > c:\temp\AfterScript_permissions.txt
Enter fullscreen mode Exit fullscreen mode

Microsoft then restarts TermService and the VM. The folder holds every machine key on the server, not just RDP's, so keep the before file with the ticket (our reading). Renaming the whole folder, the other forum fix, isn't a step in the Microsoft articles we fetched; it takes every machine key with it (our reading).

Cipher suite policy or SCHANNEL. Microsoft's article sets the SSL Cipher Suite Order policy to Not configured, then "After setting the policy to Not configured, delete the following registry value if it exists:" the policy Functions value. Do it through the GPO that set it, on one OU first. Microsoft's last step, replacing the whole SCHANNEL key and the local 00010002 key with ones exported "on a functioning machine with the same Windows version", comes with "Back up the existing key on the affected machine." Treat it as the last resort it is (our reading). If a TLS version is missing, enable TLS 1.2 for the server role rather than re-enabling every old version, and plan a restart.

Audio hang. Microsoft's step is to disable the Windows Audio service on the remote machine. Test it on one server, with the audiomode test first (Step 8).

UDP path. For one path or one group of clients, the Turn Off UDP On Client policy or the server's Select RDP transport protocols set to Use only TCP, while the network team fixes UDP 3389 (our reading).

Change one link per window, write down the old value, and keep the backup .reg with the ticket.


Step 10: Prove it from the same client (read-only, and again after a reboot)

Test from the client that failed, with the same account and the same name, then read the target's logs from the time of the change. Do it again after the next restart and Group Policy refresh, because a GPO can put a security value, a cipher list, or a certificate binding back:

# Read-only, on the client: the same connection that failed
mstsc /v:APP03.contoso.com

# Read-only, on the target: listener, port owner, and certificate after the change
qwinsta
tasklist /svc | findstr TermService
netstat -anob | findstr 3389
Get-CimInstance -Namespace 'root\cimv2\TerminalServices' -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-Tcp'" |
  Select-Object -Property SSLCertificateSHA1Hash, SSLCertificateSHA1HashType, SecurityLayer, PolicySourceSecurityLayer, UserAuthenticationRequired, MinEncryptionLevel

# Read-only: anything from the Remote Desktop logs or the System providers since the change
$changeTime = Get-Date -Date '2026-10-19 14:00'
Get-WinEvent -FilterHashtable @{ LogName='*TerminalServices*', '*RemoteDesktopServices*'; StartTime=$changeTime } -ErrorAction SilentlyContinue |
  Select-Object -Property TimeCreated, LogName, Id, LevelDisplayName, Message
Get-WinEvent -FilterHashtable @{ LogName='System'; ProviderName='TermDD', 'TermService', 'Schannel'; StartTime=$changeTime } -ErrorAction SilentlyContinue |
  Select-Object -Property TimeCreated, ProviderName, Id, Message
Enter fullscreen mode Exit fullscreen mode

Information records about normal connections are expected; what you're looking for is errors and warnings at the times the client connected (our reading).

Pass criteria (our reading): the failing client and account connect on the first try, with NLA on and the security layer back at the value you intend (SSL or Negotiate, not RDP); rdp-tcp is in Listen and TermService owns 3389 after a reboot; the listener's certificate thumbprint and type are the same after a gpupdate and a reboot; no new TermDD, Schannel, or service errors at connection times; any test value you set (the 0-and-back test, TCP only, the audio service) is back to its intended state or written down with an owner and an end date.


Common false starts

False start Why it doesn't help (our reading unless noted)
Pushing SecurityLayer 0 and UserAuthentication 0 to every server by GPO Microsoft's article uses them as a one-session test and then sets "the recommended values" back; estate-wide, it turns off server authentication and NLA
Leaving the security layer at RDP because it connected Microsoft: "If you select this setting, the RD Session Host server isn't authenticated." It hid the certificate problem instead of fixing it
Renaming the MachineKeys folder It moves every machine key on the server, not only RDP's; Microsoft's articles check and reset permissions, with before and after files
Rebuilding or re-imaging the server The listener, the port, the certificate, and the security values are all readable in minutes (Steps 4 to 6)
Deleting the RDP certificate repeatedly If it isn't re-created, one of the four services or a permission is the cause (Step 5)
Changing the RDP port to dodge a conflict Microsoft calls that "(not recommended)"; move the other application instead
Copying the RDP-Tcp or SCHANNEL key from any working server Microsoft says the source must be "a functioning machine with the same Windows version" and that you back up the existing key first
Re-enabling TLS 1.0 and 1.1 on every server It doesn't help a certificate or port problem, and Microsoft's TLS reference notes that changing enabled versions affects interoperability with every peer
Disabling the firewall to test, then forgetting it Microsoft shows Set-NetFirewallProfile for ruling the firewall out; read the Remote Desktop rules first (Step 3)
Fixing the server for one client's failure If other clients connect, start on that client (Step 8)
Treating 0x4 and 0x0 as the cause The pages we fetched don't decode them for this dialog; the target's logs and reads do (Step 2)

When a change is justified

Finding Prefer Avoid
Another process on 3389 Move that application to another port, then restart TermService Moving RDP off 3389 for every client
Listener points at a missing certificate Rebind the right certificate by thumbprint, or let the self-signed one be re-created Setting the security layer to RDP so no certificate is needed
Self-signed certificate not re-created Fix the stopped service or the permission Step 5 found Renaming MachineKeys or deleting keys by hand
Custom certificate the service can't read Give NETWORK SERVICE Read on that private key Granting Everyone or Full control on MachineKeys
MinEncryptionLevel or fAllowSecProtocolNegotiation off from Microsoft's values Fix the GPO or the local value on that server, then retest Copying the whole RDP-Tcp key from another build
Cipher suite policy broke the handshake Adjust the SSL Cipher Suite Order GPO and test on one OU Deleting cipher policy on every server at once
TLS 1.2 disabled for the server role Enable TLS 1.2, restart, retest Turning TLS 1.0 and 1.1 back on everywhere
One-minute hang, works on retry The audiomode test, then Microsoft's Windows Audio step on that server Disabling audio across the estate without testing
UDP blocked on one path TCP only for that path while the network is fixed Turning off UDP for every client everywhere

FAQ

What does "An internal error has occurred" mean in Remote Desktop?
It means the connection failed somewhere between the TCP connect and the session, and the client didn't get a more specific reason. Microsoft's article says "The issue usually occurs when the source and destination machines negotiate the security protocols, ciphers, or other encryption configurations." Read the target's logs, the listener, the certificate, and the security values before changing anything (Steps 2 to 6).

What do error code 0x4 and extended error code 0x0 mean?
The Microsoft pages we fetched don't decode 0x4 for this dialog. Microsoft's extended disconnect reason list gives 0 as "No additional information is available." if that's the same field (our reading). Treat both as a pointer to the target's logs, not as a cause (Step 2).

Does setting SecurityLayer and UserAuthentication to 0 fix it?
It's Microsoft's test, not its fix. If it connects with both at 0, Microsoft says the issue "might be related to either:" the self-signed certificate renewal or the security protocol negotiation. Put them back to 2 and 1 and fix the certificate or the negotiation (Steps 5, 7, and 9).

Why does it work from the server's console to localhost but not from my PC?
Microsoft: "If the error no longer occurs, it's related to the network." Check the port with Test-NetConnection, the Remote Desktop firewall rules, the name, and the UDP path (Steps 3 and 8).

Is this different on Windows Server 2019 and 2022?
Not in the Microsoft articles we used: they apply to supported versions of Windows Server, and the listener, port, certificate, and security values are read the same way. What differs between builds is defaults, so compare with a working server of the same version before copying any key (Steps 5 and 7).


Related posts

Free tool: SSL handshake failure and protocol version guide on SysAdmin Toolbox, with the SSL certificate checker for the certificate the RDP listener presents.

Free checklist

Pushing SecurityLayer and UserAuthentication to 0 on every server, or renaming MachineKeys across a farm, before anyone read which certificate the listener was using, is a change made everywhere at once. So is a Conditional Access policy enforced before anyone read the report-only results. The free Conditional Access pre-enforcement checklist keeps break-glass accounts, pilot groups, and report-only review on one page:

👉 https://cashflow4375.gumroad.com/l/ujkqxb?utm_source=devto&utm_medium=article&utm_campaign=aps_first_sale&utm_content=rdp-internal-error-has-occurred

If you want the rest of the Intune runway written down for the team (enrollment hygiene, compliance phasing, break/fix cards and read-only PowerShell snapshots), the Intune & M365 Admin Starter Pack pairs with this triage: https://cashflow4375.gumroad.com/l/joonf?utm_source=devto&utm_medium=article&utm_campaign=aps_first_sale&utm_content=rdp-internal-error-has-occurred


Admin Pack Studio; not affiliated with Microsoft. Steps 1-8 and 10 are read-only checks: mstsc to localhost and to the target, Test-NetConnection, Get-NetFirewallRule, qwinsta, tasklist /svc, netstat -anob, Get-NetTCPConnection, Get-NetUDPEndpoint, Get-Service, Get-WinEvent, Get-ItemProperty on the Terminal Server, RDP-Tcp, policy, Setup, ProfileList, Cryptography, and SCHANNEL keys, Get-CimInstance on Win32_TSGeneralSetting, Get-ChildItem on the certificate stores, Get-Acl and an icacls snapshot of MachineKeys, Get-ComputerInfo, and gpresult. The SecurityLayer and UserAuthentication test, restarting TermService or SessionEnv, removing or binding the RDP certificate, deleting a thumbprint value, resetting MachineKeys permissions, changing the cipher suite policy, SCHANNEL, or TLS values, changing the RDP port, disabling Windows Audio, and transport policies are deliberate changes. Change one link at a time, back up the key first, prove it from the same client after a reboot, and check current Microsoft Learn for version-specific behavior.

Top comments (0)