The only way out to fix ‘Hyper-V VM Stuck in the “Stopping/Starting” State’ is to forcibly kill the process responsible for this VM on the host OS.
As part of our Server Management Services, we assist our customers to fix similar errors.
Let us see how we restart stuck Hyper-V VMs running on Windows Server 2016/2019 without rebooting the entire host and all running VMs.
Hyper-V VM Stuck in the “Stopping/Starting” State
For instance, one of the Hyper-V VMs is stuck in the Stopping (Stopping-Critical) or Starting (Starting x%) state;
Here, the guest OS doesn’t respond. The “Turn Off”, “Shut Down” and “Reset” buttons in the Hyper-V Manager is either unavailable or return the following error:
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.
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.
Run the Task Manager and go to the Details tab. All virtual machines are running in their own instance of vmwp.exe
.
To determine which process is responsible for our VM, we need the GUID of the hung-up VM obtained earlier.
Locate the process vmwp.exe
that has the GUID of our VM in the User name column. Kill this process (End Task).
The virtual machine will be forced to stop.
[Need help to kill a Hung VM Process in Task Manager? We are available 24*7]
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:
In this case, we check the following options:
- Check that there is sufficient free space on the disk on which the Hyper-V VM files are stored;
- If an ISO image is connected in the VM settings, check its availability;
- Check the network adapter settings of the VM.
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); - Check that the Hyper-V Virtual Management Service (VMMS) is running and did not stuck in the Stopping state;
- Make sure that the antivirus software does not block access to VM files;
- Add paths to the VM directory to the antivirus exclusions;
- Check for Hyper-V related errors in the Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> Hyper-V-Worker.
[Still facing the error? We are here for you.]
Conclusion
In short, 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.
Today, we saw how our Support Engineers resolve this error for our customers.
0 Comments