Steps to kill a "Hyper-V VM Stuck in the "Stopping/Starting" State" process



To fix "Hyper-V VM Stuck in the "Stopping/Starting" State", all you need to do is to forcibly kill the process responsible for this VM on the host OS.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Software Installation on their systems.

In this context, we will look into the steps to restart stuck Hyper-V VMs running on Windows Server 2016/2019 without rebooting the entire host and all running VMs.

More about Hyper-V VM Stuck in the "Stopping/Starting" State?

Recently, one of the Hyper-V VMs is stuck in the Stopping (Stopping-Critical) or Starting (Starting x%) state.
In this case, the guest OS does not respond. The "Turn Off", "Shut Down" and "Reset" buttons in the Hyper-V Manager is either unavailable or return the following error;

The application encountered an error while attempting to change the state of VM. Failed to change state. The operation cannot be performed while the object is in its current state.


Hyper-V Manager Stuck on “Connecting to Virtual Machine Management Service”

If our Hyper-V does not show virtual machines in the Hyper-V Manager console, and returns the "Connecting to Virtual Machine Management service" error, we need to restart the vmms.exe process.

This is a safe operation and will not interrupt the running VMs. The easiest way to restart the vmms.exe process is through the vmms service using the services.msc console or with the PowerShell service management cmdlets:

Get-Service vmms | Restart-Service

How to Kill a Hung VM Process in Task Manager?

The only way to force a shutdown/restart a stuck VM without rebooting the whole Hyper-V host is to end its running workflow in the guest OS.

All VMs on the Hyper-V host starts using the vmwp.exe process. To search for a process, we need to find out the GUID of the virtual machine.
We can get the VM GUID through the Hyper-V Manager console. Open the Hyper-V server settings. In the Server section, the location of the VM configuration files is shown.

i. Open this directory in File Explorer and find the folder with the same name virtual machine has. Copy the GUID that is specified in the name of the VM configuration file with the *.vmcx extension.

ii. Run the Task Manager and go to the Details tab. All virtual machines are running in their own instance of vmwp.exe.

iii. To determine which process is responsible for our VM, we need the GUID of the hung-up VM obtained earlier.

iv. Locate the process vmwp.exe that has the GUID of our VM in the User name column. Kill this process (End Task).

v. The virtual machine will be forced to stop.

[Need help to kill a Hung VM Process in Task Manager? We are always available to help you.]


The process of Killing a Frozen Hyper-VM using PowerShell

It is easy to find and kill the process of the hung-up virtual machine using the PowerShell CLI. We need to run the PowerShell console with the administrator privileges.

In this case, the built-in Stop-VM cmdlet will not let us shutdown the VM. If we try to run the Stop-VM -Force command, it also freezes, awaiting a response from the VM.
We also need to kill the VM process by its GUID. We can get the VM GUID by its name.

For example, to get the GUID of the VM with the name SVM-GUARDEDHOST1, run the command:

$VMGUID = (Get-VM “SVM-GUARDEDHOST1”).ID


If we do not want to type the full name of the VM, we can list all the VMs registered on this Hyper-V host:

Get-VM | Select Name, Id


Copy the VM GUID from the resulting list.
Find the vmwp.exe process identifier (PID) for this VMGUID:

$VMWMProc = (Get-WmiObject Win32_Process | ? {$_.Name -match ‘VMWP’ -and $_.CommandLine -match $VMGUID})


Then, using the Stop-Process command, we must force-terminate this process:

Stop-Process ($VMWMProc.ProcessId) –Force

This is the easy way to forcefully terminate the working process of a hung-up Hyper-V virtual machine.

Hyper-V: Failed to Change VM State

Sometimes it happens that even after killing a hung-up VM process, we cannot turn on the VM.

Moreover, it freezes in the Starting state with an error:

Virtual Machine Connection Failed to Change State.

In this case, we check the following options:

i. Check that there is sufficient free space on the disk on which the Hyper-V VM files are stored;
ii. If an ISO image is connected in the VM settings, check its availability;
iii. Check the network adapter settings of the VM.
iv. Virtual network adapters must be connected to an existing Hyper-V virtual switch (there must be no status Network Adapter – Configuration Error for any NIC);
v. Check that the Hyper-V Virtual Management Service (VMMS) is running and did not stuck in the Stopping state;
vi. Make sure that the antivirus software does not block access to VM files;
vii. Add paths to the VM directory to the antivirus exclusions;
viii. Check for Hyper-V related errors in the "Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> Hyper-V-Worker".

[Still facing this error? We are here for you.]


Conclusion

Basically, if our virtual machine running on Hyper-V is stuck for some reason, the only way out is to forcibly kill the process responsible for this VM on the host OS.


Related Post


Keep In Touch

We hope to hear from you.

Accept File Type: jpg,jpeg,png,txt,pdf,doc,docx