When attempting to decommission VMware NSX, the NSX Manager UI or API reports that T0s/T1s/segments cannot be deleted because virtual machines (VMs) are still attached. This occurs even when the ESXi hosts have been successfully unprepared and no longer contain any NSX-T configuration or active segment mappings.
Symptoms:
One or more relationships exist for object or Cannot delete segment as it is in use by a virtual machine.VMware NSX 4.x
The issue is caused by stale metadata or "ghost" entries within the NSX Management Plane database. A synchronization mismatch occurs where the Policy or Manager components maintain a record of vNIC attachments (Realized State) that no longer exist on the physical data plane (ESXi hosts). Because the database believes dependencies exist, it blocks the deletion of segments, routers, and transport node configurations.
Since the vSphere infrastructure is already decoupled and the end goal is total decommissioning, the management components can be manually removed.
Decommission NSX Management Components: