Unable to remove server that still has locked instances on it

I’m trying to delete an instance from Morpheus and getting the error “Unable to remove server that still has locked instances on it”. Delete button is grayed out but force delete is throwing lock error. Please suggest how to fix the issue or is there any other way to delete the locked instances?

Hi @ajayk ,

You are at the server/host level. Servers exist within instances (Provisioning > Instances, or click on the Instance: url within the info section of your server. From here, you can see Actions > Unlock/Lock. You must unlock the instance before you can either delete the instance or servers within.

Instance URL in Info Section:


Thank you, this is really great feature, this prevent accidental instance deletion.

I would like to enable this lock on around 700 + systems in my Morpheus prod environment, any script/automation is available to push it on bulk VMs Please ?. Its pain to do it manually. Appreciate if any help here. Thanks in Advance.

You can set the lock via the API at the Lock an Instance Endpoint (and possibly CLI but did not confirm) to do this in bulk easier.

@ajayk I’ve created a script to automate this:

You might want to edit the logic slightly to meet your use-case.

Hope it helps!

Thank you for the script, much appreciated :slight_smile: I am planning to enable lock only on selected production instances, i Need some modification in the script like i can list instances details in CSV or txt file and then run script, so that i can enable lock only one specific instances not on all. Sorry i am not a python guy, so appreciate your help in modify the script.

No worries.

You’ll need to set a filter on the Get All Instances API call - have you had a chance to check out the API documentation?

What is the criteria for instances you want to enable the lock on? Instances with a particular name or status (‘running’, ‘stopped’, etc…)? Something else?

Thanks for the quick response.
Would like to enable lock on Instances with particular name.


Just set a ‘name’ filter in the API call to get all instances with a particular name/naming pattern and then update the ‘url’ in the script by adding a query parameter called name and a value specifying whatever the name filter is.

E.g. if I want to retrieve all instances with ‘test’ in the name, the URL would look something like this:

url = "https://<MORPHEUS-APPLIANCE-URL>/api/instances?max=25&offset=0&name=test&showDeleted=false&details=false"