Home/Tutorials/Azure/Error fix
Error fixAzure · 3 min read · Updated 5 Dec 2026

Cannot Connect to Azure VM (RDP or SSH): How to Fix

Azure VM RDP or SSH not working? Check NSG rules, public IP, VM status, Just-in-Time access and guest firewall, or connect safely with Azure Bastion.

QUICK ANSWERIf you cannot RDP (port 3389) or SSH (port 22) into an Azure VM, check: the VM is running, it has a public IP (or you are on the VNet), the Network Security Groups on both the NIC and the subnet allow your IP on that port, Just-in-Time access is not blocking you, and the guest OS firewall allows it. Azure Bastion avoids public IPs and open ports altogether, and "Connection troubleshoot" in Network Watcher shows which rule blocks you.
Cannot connect to Azure VM: causes and fixes
Cannot connect to Azure VM: causes and fixes

Quick checklist

CheckWhere
VM is Running (not Stopped/Deallocated)VM overview page
Public IP exists and you use itVM → Networking
NSG on NIC and on subnet both allow your IP on 22/3389VM → Networking → Inbound rules (effective rules)
Just-in-Time (Defender for Cloud) request approvedVM → Connect → JIT
Guest firewall / sshd / RDP service runningSerial console or Run Command
Your network allows outbound 22/3389Try a mobile hotspot

Fix it step by step

  1. Open VM → Connect and run the built-in connection check; it tests NSG rules and VM status.
  2. Look at effective security rules for the NIC: an NSG on the subnet and another on the NIC must both allow the traffic.
  3. Add an inbound rule for TCP 22 or 3389 with source = your public IP only, priority lower (higher precedence) than any deny rule.
  4. If the VM has no public IP, connect through Azure Bastion, a VPN, or a jump box in the VNet.
  5. If you can reach the port but login fails: reset the password or SSH key with Reset password (VMAccess extension).
  6. If the OS is broken (firewall rule, full disk, sshd stopped), use Serial console or Run command to fix it without network access.
  7. Use Network Watcher IP flow verify to see exactly which NSG rule allows or denies your packet.

Safer options

Azure Bastion gives RDP and SSH in the browser over HTTPS, with no public IP on the VM. Just-in-Time VM access keeps ports closed and opens them only for your IP for a limited time after you request it. Both are standard in companies, and opening 3389 to the whole internet is a common way VMs get compromised.

Questions

Why did RDP stop working after I stopped the VM?

A dynamic public IP is released when the VM is deallocated, so it may change on start. Use a static public IP or Bastion.

NSG on subnet and NIC: which wins?

Both apply. Inbound traffic must be allowed by the subnet NSG and then by the NIC NSG.