How to Terminate Unresponsive ESXi VMs
Issue
Sometimes virtual machines become unresponsive - they cannot be connected to via SSH or VMware's console, and attempting to shut them down or forcefully power them off in the ESXi web client also fails. In such cases, the VMs must be terminated via CLI.
Fix
- If you haven't already, enable SSH on your ESXi host:
- SSH into your ESXi host and follow any one of the two methods below.
Method 1 - Using Stop-VM
Stop-VM -kill <name> -Confirm:$false
Where <name>
is the display name of the VM you wish to stop.
Method 2 - Using ESXCLI
- Get the World ID of the VM you wish to stop:
esxcli vm process list
- Copy & paste the VM's World ID into the following command:
esxcli vm process kill --type=soft -w=<world_id>
Explanation
type=x
: Specifies how we want to terminate the VM.
soft
: gracefully shutdowns the VM. It's best to attempt this way first.hard
: immediately kills the VM.force
: kills the VM process on the host. Use this only as a last resort, you may lose data.