VM in virtualbox is already locked for a session (or being unlocked)

Virtualbox

Virtualbox Problem Overview


My VM in virtualbox can not start due to this error, I don't want to destroy it and reinstall it again, anyway to recover it ?

There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "319fcce3-e8ff-4b6f-a641-3aee1df6543f", "--natpf1", "delete", "ssh"]

Stderr: VBoxManage: error: The machine 'centos64_c6402_1454036461345_59755' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 493 of file VBoxManageModifyVM.cpp

Virtualbox Solutions


Solution 1 - Virtualbox

Running this on the command line unlocked the VM:

vboxmanage startvm <vm-uuid> --type emergencystop

Where <vm-uuid> is the number in the error message: Command: ["modifyvm", "<vm-uuid>" [...]. After that I was able to control the VM (start, halt, etc). Using Virtualbox 4.1 on Ubuntu.

Solution 2 - Virtualbox

Having the same issue I found that there was a process running actually locking the vm:

501 79419 79323   0  2:18PM ??         0:39.75 /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless --comment default --startvm 1d438a2e-68d7-4ba2-bef9-4ea162913c1b --vrde config

Make sure you don't have a process stuck trying to start the vm:

ps -ef | grep -i "vbox"

Solution 3 - Virtualbox

I found this answer from @Gonzalez very interesting.

vboxmanage startvm <vm-uuid> --type emergencystop

The only problem with that it shut down the current instance of my VM, so instead of using modifyvm you can use controlvm if the current vm is running.

For example:

 VBoxManage modifyvm <vm_name> --natpf1 "guestssh,tcp,,22,,2222"
 VBoxManage modifyvm <vm_name> --natpf1 delete "guestssh"

Become:

VBoxManage controlvm <vm_name> natpf1 "guestssh,tcp,,22,,2222"
VBoxManage controlvm <vm_name> natpf1 delete "guestssh"

Full documentation Here https://www.virtualbox.org/manual/ch08.html#vboxmanage-controlvm

Solution 4 - Virtualbox

For me I had to kill the VboxHeadless.exe process in task manager. I also had to ensure CMD prompt was opened in Administrative mode.

Solution 5 - Virtualbox

sudo pkill -9 VBox kills everything running related to vbox

Solution 6 - Virtualbox

In Windows Task Manager, I ended any tasks related to Virtual Box (you can see they start with a V in Task Manager like Vbox Headless.exe, etc). Once I did that, I was able to get this error to go away (the above 'vboxmanage startvm ...etc...' solutions here did not work for me).

Solution 7 - Virtualbox

If you have a settings window open for that box in the VirtualBox GUI, you may run into this error. Just close the settings window and try again.

Solution 8 - Virtualbox

I've encounter the same error message today:

>me@myhost:~$ ps -ef | grep -i "vbox"

me  3064     1  0 08:51 ?        00:00:00 /usr/lib/virtualbox/VBoxXPCOMIPCD

me  3089     1  0 08:51 ?        00:00:00 /usr/lib/virtualbox/VBoxSVC --auto-shutdown

me  3126  3089 27 08:51 ?        00:00:39 /usr/lib/virtualbox/VBoxHeadless --comment RHEL5 64-bit desktop --startvm e5c598d8-1234-4003-a7c1-b9d8af15dfe7 --vrde config

me  3861  3415  0 08:53 pts/1    00:00:00 grep --color=auto -i vbox*

Gergely's answer solves it perfectly. It turned out that I've a crontab set at reboot to boot the virtual machine, which initiated the three VBox process shown above

me@myhost:~$ crontab -l

@reboot me /usr/bin/vboxmanage startvm "RHEL5 64-bit desktop" --type headless

Solution 9 - Virtualbox

The only option that worked for me was to kill all the processes matching ps axl|grep -i vbox.

Solution 10 - Virtualbox

In my case, the apparent cause was a USB ethernet adapter that had been removed after suspending the machine. In my case,

vboxmanage startvm <vm-uuid> --type emergencystop

did not help. Instead, I received the confusing message that

> VBoxManage: error: The machine 'xyzzy' is not locked by a session

The true error was revealed by running

vboxmanage startvm <vm-uuid> --type gui

which returned

> VBoxManage: error: Nonexistent host networking interface, name 'en9: USBPlug' (VERR_INTERNAL_ERROR)

Changing the network configuration to a different network adapter solved the issue.

Solution 11 - Virtualbox

This is because You reallocated the memory set for Virtual Box
What you have to do to fix is: Restart The PC

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzjffduView Question on Stackoverflow
Solution 1 - VirtualboxGonzalo MatheuView Answer on Stackoverflow
Solution 2 - VirtualboxGergely TothView Answer on Stackoverflow
Solution 3 - VirtualboxErmanView Answer on Stackoverflow
Solution 4 - Virtualboxjreed350zView Answer on Stackoverflow
Solution 5 - VirtualboxJanaView Answer on Stackoverflow
Solution 6 - Virtualboxarmyofda12mnkeysView Answer on Stackoverflow
Solution 7 - VirtualboxJohn BrandenburgView Answer on Stackoverflow
Solution 8 - VirtualboxX.XView Answer on Stackoverflow
Solution 9 - VirtualboxCharles ThomasView Answer on Stackoverflow
Solution 10 - VirtualboxzeeMonkeezView Answer on Stackoverflow
Solution 11 - VirtualboxObed AmoakoView Answer on Stackoverflow