The error code 0x4 with extended error code 0x0 can occur due to various reasons, such as network configuration, RDP settings, or encryption issues. Here are some steps you can try to resolve this:
- You can try to reboot the VM through the Azure portal or from Bastion via command line - Restart-Computer.
- Ensure the Network Security Group associated with your VM allows inbound traffic on port 3389 (RDP). Go to the Network Security Group associated with your VM and ensure there is a rule allowing TCP traffic on port 3389 for RDP.
- If the public IP address of the VM changes, your DNS cache might still have the old IP. Run the following command on your local machine: ipconfig /flushdns
- Ensure RDP is enabled on the VM. You can check this by logging in via Bastion and verifying the settings in the System Properties under "Remote Desktop".
- Ensure the Windows Firewall on the VM is not blocking RDP. Connect to your VM via Bastion, Open the Windows Firewall and ensure the Remote Desktop rule is enabled.
Open the Control Panel > Windows Defender Firewall > Allow an app or feature through Windows Defender Firewall, and ensure Remote Desktop is allowed. - In the Azure portal, navigate to your VM. Under the Support + troubleshooting section, select Reset password. Choose the Reset configuration only option and click Update. This will reset the RDP configuration.
- Connect to the VM via Bastion, open the run dialog, type services.msc to open services window and then restart the following 2 services: Remote Desktop Services, Remote Desktop Services UserMode Port Redirector
- Open computer management in the VM, navigate to Local Users and Groups and ensure that you are part of Remote Desktop users' group.
Additional references:
https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/troubleshoot-rdp-internal-error
https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/windows/troubleshoot-rdp-connection
https://learn.microsoft.com/en-us/answers/questions/1305623/unable-to-connect-to-vm-via-rdp-or-bastion-tried-a
Hope this helps!
Please Let me know if you have any queries.
If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as a token of appreciation. Thank You.