Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Virtualization / VMware / How to Stop an Unresponsive (Stuck) Virtual Machine on VMware ESXi

March 15, 2024

How to Stop an Unresponsive (Stuck) Virtual Machine on VMware ESXi

Sometimes, the running virtual machine on the VMware ESXi host might freeze and not respond to the vSphere Client shutdown or restart command. In this article, we will find out how to force a VMWare virtual machine to power off when it becomes unresponsive (stuck).

When the virtual machine process on the ESXi server freezes, it stops responding to Reset/Power Off commands and any action results in an error such as:

  • Another task is already in progress;
  • The virtual machine might be performing concurrent operations. Actions: Complete the concurrent operation and retry the power-off operation; The virtual machine is in an invalid state;
  • The attempted operation cannot be performed in the current state.

You can manually stop a stuck VM process on an ESXi host from the local ESXi shell or with PowerCLI commands without having to restart the server. Note that data loss in the guest operating system may occur if you force a VM shutdown (this is similar to the case when the power cord is disconnected from a physical computer).

Before forcibly killing the VM, verify that the problem is not caused by another ESXi host locking its files in the datastore.
  1. First, identify the ESXi host running a hung VM;
  2. Open vSphere Client and find the VM. The ESXi host name on which the VM is running is specified on the Summary tab in the Related Object -> Host section;vmware vsphere client get vm host
  3. Enable SSH on this ESXi host;
  4. Connect to ESXi using an SSH client (you can use the built-in Windows OpenSSH client);
  5. List the running VMs:$ esxcli vm process list
    esxcli vm process list
  6. Copy the ID of the virtual machine you need (World ID);
  7. Use the following command to forcibly kill a stuck virtual machine process on the ESXi hypervisor:
    $ esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber

There are three options to kill the VM process on an ESXi host:

  • Soft – the safest way to kill the VMX process (similar to kill -SIGTERM);
  • Hard – stop the VM process immediately (kill -9);
  • Force – used as a last resort if other options fail.
Ensure that there are no active snapshots, backup, or other jobs for the virtual machine and that the virtual machine doesn’t have the Virtual Machine disks consolidation is needed status. Otherwise, you can break your VM and you will need to restore it from a backup.

Try to perform a soft stop of the VM with the specified ID:

$ esxcli vm process kill --type=soft -w=20598249

esxcli vm process kill

The VM should shut down gracefully.

You can shut down a stuck virtual machine using PowerShell. This can be useful because when connecting to vCenter, there is no need to find the host where the VM is running and enable the SSH service on it. Connect to vCenter using PowerCLI and check if the VM is running:

Connect-VIServer <vCenter_or_ESXi_FQDN>
Get-VM “web1" | select name,PowerStates

Force stop the VM process with the command:

Stop-VM -kill "web1" -confirm:$false

PowerCLI stop-vm -kill

The ESXTOP utility can also be used to stop an unresponsive VMWare virtual machine.

Run the esxtop in an SSH session, then press c to display CPU resources and SHIFT+V to view virtual machine processes only.

esxtop

Then press f (select columns to display), c (to display the LWID, Leader World ID), and then press ENTER.

esxtop get vm lwid

Find your VM in the list and remember its LWID. Press k (kill) and type the LWID identifier of the VM you want to force stop.

The final option for the hard shutdown of a virtual machine is the use of the kill tool. This method allows you to kill not only the VM but also any child processes.

Get the VM’s parent process ID:

ps | grep "web2"

Kill the VM process:

kill -9 24288474

esxi kill vm process with ps

The installed guest operating system will boot in recovery mode after a hard reset (the Windows Recovery Environment (WinRE) will start in the case of a Windows guest). Windows Error Recovery

If this does not help either, you can try to restart the hostd and vpxa management services on the ESXi host:

$ /etc/init.d/hostd restart
$ /etc/init.d/vpxa restart

1 comment
5
Facebook Twitter Google + Pinterest
VMware
previous post
SQL Server: Could Not Find the Database Engine Startup Handle
next post
Implementing Dynamic Groups in Active Directory with PowerShell

Related Reading

Match Windows Disks to VMWare VMDK Files

March 12, 2024

VMWare Error: Unable to Access a File Since...

March 15, 2024

Invalid State of a Virtual Machine on VMWare...

March 12, 2024

Unable to Unmount/Delete VMFS Datastore: The Resource Is...

March 12, 2024

Configuring USB Devices Passthrough from VMWare ESXi to...

March 12, 2024

Selecting the Number of vCPUs and Cores for...

March 12, 2024

How to Enable and Configure SNMP on VMWare...

March 15, 2024

VMWare vSphere: Managing Password Expiration Settings

March 13, 2020

1 comment

Marsellus Maynard November 26, 2016 - 7:25 pm

Great post! esxtop rocks!!

You can also use: esxcli or PowerCLI.

– esxcli:

esxcli vm process kill

– PowerCLI cmd-let:

Stop-VM with -Confirm:$false

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Invalid State of a Virtual Machine on VMWare ESXi
  • Match Windows Disks to VMWare VMDK Files
  • Configuring USB Devices Passthrough from VMWare ESXi to a Virtual Machine
  • How to Enable and Configure SNMP on VMWare ESXi Host
  • Selecting the Number of vCPUs and Cores for a Virtual Machine
  • Unable to Unmount/Delete VMFS Datastore: The Resource Is in Use
  • VMWare vSphere: Managing Password Expiration Settings
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top