Unable to unregister virtual machine showing power off status in ESXi 8
search cancel

Unable to unregister virtual machine showing power off status in ESXi 8

book

Article ID: 414127

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

In VMware ESXi 8.x, attempting to unregister a virtual machine (VM) that appears powered off from the vSphere Client  fails.

  • The VM is displayed as "Powered Off" in the vSphere Client.
  • When attempting to unregister/delete, an error similar to the following may occur:
    The operation is not allowed in the current state.
  • The VM directory cannot be deleted or moved because it is still locked by the host.

Environment

  • VMware vSphere ESXi 8.0
  • VMware vCenter Server 8.0

Cause

This issue occurs when a stale or orphaned process associated with the virtual machine remains active on the ESXi host.
Even though the VM appears as powered off, the stale process keeps file locks on the VMX or VMDK files, preventing the unregister operation.

Possible causes of the stale process include:

  • An unexpected interruption during VM power-off.
  • Network or vCenter communication loss during VM state transition.
  • ESXi host process (vmx) not properly released after VM shutdown.

Resolution

Manually identify and terminate the stale VM process on the ESXi host.

Important: Ensure that the VM is actually powered off and that no valid process is running before terminating any process.

  1. SSH to the ESXi Host
    • Enable SSH service on the ESXi host from vSphere Client:
      • Navigate to Host > Manage > Services.
      • Locate TSM-SSH, click Start.
    • Use an SSH client (such as PuTTY) to connect to the ESXi host.

  2. Identify the VM Process
    1. Run the following command to list all running VMs and their associated process IDs:
      esxcli vm process list

      Example output:
      TEST-01
      World ID: 123456
      Process ID: 3425012
      Display Name: TEST-01

    2. Locate the VM that cannot be unregistered.

  3. Terminate the Stale Process
    1. Run the following command, replacing <World ID> with the actual value found in the previous step:
      esxcli vm process kill --type=force --world-id=<World ID>

    2. If the above command does not terminate the process, you can manually kill the PID:
      kill -9 <Process ID>

      Note: Use kill -9 only if the process does not stop with the esxcli command. Improper termination may lead to VM file corruption if the VM is actually running.

  4. Verify and Unregister the VM
    1. Verify the VM process is no longer listed:
      esxcli vm process list

      The VM should no longer appear.

    2. Return to the vSphere Client, right-click the VM and select Remove from Inventory (Unregister).
    3. The VM should now unregister successfully.