Remote Desktop error 0x904 means the connection to the remote PC opened and then closed before the session could start: Microsoft's reference for its Remote Desktop client control lists code 2308 (0x904) as "Socket closed", shown to users as "The connection to the remote computer was lost, possibly due to network connectivity problems." It is not the "port 3389 unreachable" error (that is 0x204); something on the path or on the server hung up after first contact, and the extended code next to it, such as 0x7 or 0x5, tells you which side.
On a Windows VPS from RS Computers in Amsterdam, Dublin or Prishtina, the client area also has a console that shows the server's screen without RDP, so you can fix the server side while Windows App or Remote Desktop Connection keeps failing.
Quick fix, in this order
- Read the extended code.
0x7means the server refused,0x5that another connection took your session,0x0or none that the network dropped it. The table below has the rest.- Turn off the VPN, or switch from Wi-Fi to a phone hotspot, and try again. If it works there, the problem is the path, not the server.
- Test the port:
nc -vz YOUR_SERVER_IP 3389in the Mac Terminal, orTest-NetConnection -ComputerName YOUR_SERVER_IP -Port 3389in PowerShell on Windows.- Connect by IP address instead of the host name, to rule out DNS.
- Update Windows App or Windows, then restart the Remote Desktop service on the server from its console.
Key facts, checked on 19 November 2026:
- Microsoft's OnDisconnected reference names 0x904
disconnectReasonAtClientWinsockFDCLOSE, "Socket closed". 0x204 is "Windows Sockets connect failed", 0x104 a DNS lookup failure, 0x108 a time-out. - Extended codes come from Microsoft's ExtendedDisconnectReasonCode list: 7 is "The server denied the connection", 5 "The client's connection was replaced by another connection".
- Windows App's troubleshooting page (updated 4 November 2026) lists no error codes.
- RDP uses TCP and UDP 3389; an RD Gateway takes TCP 443 and UDP 3391 (Ports used by RDS).
- A passing port test doesn't rule out 0x904. In our lab, a listener that accepted connections and closed them at once still made
ncprintsucceeded!.
What 0x904 means, and what the extended code adds
0x904 says how the connection ended; the extended code says why, when the client knows. We asked the Remote Desktop control on a Windows 10 PC (build 19044) to describe each pair, using the method in Microsoft's archived disconnect-codes article; the middle column is what Windows returned.
| Extended code | Text Windows shows | What to do |
|---|---|---|
0x0 or none | "The connection to the remote computer was lost, possibly due to network connectivity problems." | Network drop: VPN, Wi-Fi, MTU or UDP. Try another network, then the port test |
0x3 | "...ended because the remote computer didn't receive any input from you." | Idle limit: policy "Set time limit for active but idle Remote Desktop Services sessions" |
0x4 | "The remote session ended because the total logon time limit was reached." | Policy "Set time limit for active Remote Desktop Services sessions" |
0x5 | "You have been disconnected because another connection was made to the remote computer." | Another device or user took the session. Session limits |
0x7 | "This computer can't connect to the remote computer. Try connecting again..." | Server refused after contact: security layer, NLA, certificate or a stuck service. Server checks |
0x8 | "The client could not establish a connection..." (remote connections off, too many connections, network error or FIPS level) | Check Remote Desktop is on and seats are free |
0x9 | "The connection was denied because the user account is not authorized for remote login." | Give the account Remote Desktop rights |
Both time limits sit under Computer Configuration, Administrative Templates, Windows Components, Remote Desktop Services, Remote Desktop Session Host, Session Time Limits (Policy CSP). To decode any pair yourself, PowerShell accepts the hex values as written:
# PowerShell as your normal user, on any Windows PC
$rdp = New-Object -ComObject MSTscAx.MsTscAx
$rdp.GetErrorDescription(0x904, 0x7)
On our PC it printed:
This computer can't connect to the remote computer.
Try connecting again. If the problem continues, contact the owner of the remote computer or your network administrator.
What the error looks like on Windows, Mac, iPhone and Android
Remote Desktop Connection on Windows shows Microsoft's text with "Error code: 0x904" and an "Extended error code" line. Windows App on Mac, iPhone, iPad and Android shows the hex code in its error dialog. On Mac, Windows App is what used to be Microsoft Remote Desktop: Microsoft says the old macOS client "isn't available for download anymore and it's replaced by Windows App" (Microsoft Learn). Microsoft publishes no list of Windows App dialog texts, so search by the code; "failed due to network related issues 904" describes the same network-side close.
Microsoft's reference covers its Windows client control and doesn't promise identical meanings in the Mac and mobile apps, so there, confirm with the tests below. Neighbouring codes:
| Code | Microsoft's name | Means for you |
|---|---|---|
0x204 | Socket connect failed | Never reached port 3389: port 3389 checks |
0x104, 0x508 | DNS lookup failed | The name doesn't resolve; use the IP or fix DNS |
0x108 | Connection timed out | Packets dropped on the way, often a firewall |
0x904 | Socket closed | Connected, then closed: this article |
0x906 | Internal security error | TLS or NLA handshake: stuck at "Securing remote connection" |
0x907 | Unexpected server authentication certificate (2311) | The server's certificate changed |
Causes of 0x904, most common first
1. Port 3389 is blocked, or a firewall cuts RDP after the handshake
A plain block usually gives 0x204. 0x904 appears when something accepts the TCP connection and then closes it. In one Microsoft Q&A thread the user's port test succeeded and other users could connect; a reply pointed to application-aware firewalls that pass TCP tests but block RDP traffic (Microsoft Q&A, December 2024).
2. Wrong host or DNS
An old DNS record can send you to a machine that answers on 3389 but isn't your server. When 0x904 reports followed Windows 11 22H2, a Microsoft Q&A moderator called it a bug and suggested the server's IP address instead of the hostname (Microsoft Q&A, 2022), still the fastest DNS test.
3. NLA, TLS or security layer mismatch
If the two sides can't agree on security, the server closes the connection; missing CredSSP updates on one side are the classic case. Our security error section has Microsoft's checks and a safe way to test the security layer.
4. A broken or replaced RDP certificate
A self-signed RDP certificate without its private key, or one Windows can't renew, ends the handshake; re-creating it is in the same section. With 0x907 the certificate changed since your last visit: expected after a reinstall, suspicious otherwise.
5. RD Gateway problems
Through a gateway, your device talks to the gateway on TCP 443 and the gateway to the PC on 3389; either hop can close. Test the gateway name on port 443 too.
6. A VPN that is required, or one that breaks the path
Many servers accept RDP only from a VPN. A VPN that shrinks packets below 1,500 bytes lets small packets through and loses the large ones of the handshake. Our MTU and VPN fix finds the right size.
7. UDP trouble
A network that passes the first UDP packets and drops the rest can end the session. On Windows, the policy "Turn Off UDP On Client" under Computer Configuration, Administrative Templates, Windows Components, Remote Desktop Services, Remote Desktop Connection Client makes Remote Desktop traffic "only use the TCP protocol" (Policy CSP). The registry version and how to undo it are in our UDP fix.
8. Session limits on the server
Windows Server takes two Remote Desktop connections at once without RDS licences (Microsoft Learn). Extended code 0x5 means a second connection took your session. With the policy "Restrict Remote Desktop Services users to a single Remote Desktop Services session" enabled, each user gets one session (Policy CSP), so your phone pushes your Mac out. Free stale sessions with our session steps.
Test from a Mac or Linux with nc
Open Terminal (Applications, Utilities) on a Mac, or a terminal on Linux, and use the address you put in Windows App:
# Terminal on your Mac, as your normal user
nc -vz YOUR_SERVER_IP 3389
# on Linux (package netcat-openbsd), with a 5-second limit
nc -vz -w 5 YOUR_SERVER_IP 3389
We ran the Linux command in a Debian 13 container (OpenBSD netcat 1.229) against an open, a closed and a silently dropped port. The Mac's netcat may word it slightly differently. If it hangs on a Mac, press Control-C after 15 seconds: the hang is the answer.
| nc output in our lab | Time | Meaning |
|---|---|---|
Connection to ... 3389 port [tcp/ms-wbt-server] succeeded! | 0.00 s | TCP works; 0x904 comes from later: security, certificate, UDP, MTU or the server |
nc: connect to ... port 3389 (tcp) failed: Connection refused | 0.00 s | Server up, nothing listening: Remote Desktop off or its service stopped |
nc: connect to ... port 3389 (tcp) timed out: Operation now in progress | 5.00 s | A firewall drops the packets, or the address is wrong |
nc: getaddrinfo for host "..." port 3389: Name or service not known | - | The name doesn't resolve: DNS |
The catch: our accept-and-close listener also printed succeeded!, so it proves the path to 3389 is open, not that RDP survives on it. For packet size, our lab showed a 1,500-byte path; 1,473 bytes of data plus 28 of headers don't fit:
# on Linux, as your normal user
ping -c 2 -M do -s 1472 YOUR_SERVER_IP
ping -c 2 -M do -s 1473 YOUR_SERVER_IP
1480 bytes from ...: icmp_seq=1 ttl=53 time=1.03 ms
...
ping: sendmsg: Message too long
Through a VPN the first line may fail too; lower the size until it answers. Many servers block ping, so no reply at any size proves nothing.
Test from Windows with Test-NetConnection
Microsoft's can't-connect article uses this check. When the port fails, Windows also pings, exposing a common trap: ping works, 3389 doesn't. Our output from a Windows 10 PC, address and interface lines removed:
# PowerShell as your normal user
Test-NetConnection -ComputerName YOUR_SERVER_IP -Port 3389
WARNING: TCP connect to (YOUR_SERVER_IP : 3389) failed
ComputerName : YOUR_SERVER_IP
RemotePort : 3389
PingSucceeded : True
PingReplyDetails (RTT) : 33 ms
TcpTestSucceeded : False
For packet size, Microsoft's ping reference says /f "is useful for troubleshooting path Maximum Transmission Unit (PMTU) problems". On our PC, 1,472 bytes passed and 1,473 printed Packet needs to be fragmented but DF set.:
:: Command Prompt on your own PC, with the VPN connected if you use one
ping /f /l 1472 YOUR_SERVER_IP
Remote Desktop Connection also logs each disconnect: Microsoft's archived article names the log Microsoft-Windows-TerminalServices-RDPClient/Operational, event ID 1026, with lines like RDP ClientActiveX has been disconnected (Reason= 263). Reason 2308 is 0x904. To list the latest:
# PowerShell as your normal user
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-TerminalServices-RDPClient/Operational'; Id=1026} -MaxEvents 5 | Format-List TimeCreated, Message
Windows App for Windows has no network settings, Microsoft says (network settings), so on Windows the levers are the VPN and the UDP policy.
Server-side checks from the console
If every device on every network gets 0x904, look at the server. From its console, in this order:
- The listener: Microsoft's check is
qwinstain an administrator Command Prompt, where a linerdp-tcpin stateListenmeans it runs, andnetstat -anob | findstr 3389shows who holds the port (Microsoft Learn). - The service: in the Q&A thread above, a reply suggested retrying right after restarting the Remote Desktop service, and another user reported the error gone after a restart. Do it from the console, because it ends every session:
Restart-Service -Name TermService -Forcein an administrator PowerShell window. - The certificate and security layer: Microsoft's four checks in our security error section.
- Sessions:
query userlists who holds the seats. - The firewall rule: if you limited 3389 to your IP, check it still matches your current address. Our guide to securing RDP on Windows Server has the tested commands.
Windows App settings to try on Mac, iPhone, iPad and Android
Menu names are from Microsoft's Windows App documentation, checked on 19 November 2026.
- Update the app: Microsoft's first step is "Make sure you're using the latest version of Windows App" (What's new in Windows App). Its reset on Mac, iPhone and iPad is removing the app and installing it again.
- The PC entry: on the Devices tab, select the ellipsis (...) on the PC's card, then Edit. Try the IP address as PC Name, and on the General tab check the Gateway drop-down; leave it empty unless you use a gateway (network settings).
- Gateways on a Mac: menu bar, Windows App, Settings, Gateways tab on the Preferences pane. On the PC's General tab, Bypass for local addresses skips the gateway on your own network.
- Proxy: on Mac, Settings, General tab, Use system proxy configuration; on iPhone and iPad, the cog, General, Use HTTP Proxy. Switch it off for one test. Microsoft documents these network settings for Mac and iOS/iPadOS only.
- Local network access on a Mac, for a PC on your own network: System Settings, Privacy & Security, Local Network, then turn access on for Windows App (Apple Support). On iPhone and iPad, Microsoft says to tap Allow when the app asks to connect to devices on your local network (Get started).
- Android: Microsoft documents no network settings; test over mobile data instead of Wi-Fi.
Frequently asked questions
What does Remote Desktop error 0x904 mean?
Microsoft's reference for its Remote Desktop client control lists 0x904 (2308) as "Socket closed": the connection opened and was then lost, "possibly due to network connectivity problems". The extended error code next to it gives the reason, for example 0x7 when the server denied the connection.
What is error code 0x904 with extended error code 0x7?
The connection reached the server and the server refused to continue; Microsoft's extended code 7 is "The server denied the connection". Check NLA and security layer settings, the RDP certificate and the Remote Desktop service on the server, and compare with another user or device.
What does extended error code 0x5 mean?
Another connection replaced yours. Windows shows "You have been disconnected because another connection was made to the remote computer", typically when the same account signs in from a second device or a single-session policy is on.
Why do I get 0x904 in Windows App on my Mac but not on Windows?
Usually the Mac takes a different path: a VPN, Wi-Fi, a proxy or a gateway set in Windows App. Run nc -vz YOUR_SERVER_IP 3389 in Terminal, try the IP address, check Local Network in Privacy & Security, and update Windows App.
Is 0x904 the same as 0x204?
No. 0x204 means the client never reached port 3389. 0x904 means it connected and the connection then closed, so look at the VPN, UDP, packet size, security settings and the server.
Can a VPN cause error 0x904?
Yes. A VPN can shrink packets below what the RDP handshake needs, or drop UDP after the first packets. Try once without it; if the server only accepts VPN connections, test packet size with ping /f /l 1472 on Windows or ping -M do -s 1472 on Linux.
Need a hand?
If another network, no VPN and the IP address didn't clear it, the server is next, and that is where we can help:
- For Windows with a console that works when RDP doesn't: a Windows VPS or VDS in Amsterdam, Dublin or Prishtina, each with its own IPv4 and IPv6.
- For several Remote Desktop users at once: a VDS with dedicated vCPUs and NVMe in the same three cities.
- Custom offers, custom setups and systems built for you, such as RDP reachable only through a VPN, quoted per job: write to us on Telegram or at info@rscomputers-ks.com.