Unable to connect to Azure VM

Bedekar, Tushar 0 Reputation points
2025-04-28T07:48:41.83+00:00

I am trying to connect to Azure VM using RDP. I am able to login via bastion.

I have configured the ports correctly and I get password box after connecting. Once I enter the password, I see an error like below:

An internal error has occured.

Error code: 0x4

Extended Error code: 0x0

Timestamp: XYZ

Any help is much appreciated.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,787 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 115 Reputation points Microsoft External Staff Moderator
    2025-04-28T09:26:09.2266667+00:00

    Hi Bedekar, Tushar

    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:

    1. You can try to reboot the VM through the Azure portal or from Bastion via command line - Restart-Computer.
    2. 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.
    3. 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
    4. 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".
    5. 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.
    6. 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.
    7. 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
    8. 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.

    0 comments No comments

  2. Alex Burlachenko 4,875 Reputation points
    2025-04-30T08:13:16.2766667+00:00

    Hi Tushar,

    Thank you for posting your question on the Q&A portal! The Azure community is always happy to help, and I’ll do my best to provide a clear solution. You’re unable to RDP into your Azure VM, though Bastion works. After entering your password, you receive an "Internal Error" (0x4). So I would recommend firstly see the NSG or Firewall Blocking RDP Traffic. Even if Bastion works, standard RDP port is 3389 might be blocked. Verify that your NSG allows inbound TCP/3389 from your IP.

    Configure NSGs for RDP https://learn.microsoft.com/en-us/azure/virtual-network/manage-network-security-group?tabs=network-security-group-portal#create-security-rules

    As well we cant exclude vm resource allocation issue. The error can occur if the VM is under heavy load or out of resources. Restart the VM via the Azure Portal (Stop > Start).

    Next possible issue could be corrupted RDP Session or Credentials. Clear cached credentials on your local machine. Open Command Prompt > Run cmdkey /delete:<VM_IP>

    Try RDP again with fresh credentials.

    And we cant exclde Windows VM Configuration Issue. The Remote Desktop service might be misconfigured. Use Bastion to log in and check Run services.msc > Ensure "Remote Desktop Services" is running. Run gpresult /h report.html > Check Group Policy isn’t blocking RDP.

    If Bastion works, use it to inspect the VM’s event logs (Event Viewer > Windows Logs > Application/System) for RDP-related errors.

    Temporarily enable Boot Diagnostics in the Azure Portal to check for startup issues.

    Let me know if you need further clarification! The community and I are here to assist.

    Best regards,
    Alex
    P.S. If my answer help to you, please Accept my answer
    PPS That is my Answer and not a Comment
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.