Unable to uninstall NSX on the ESXi host using 'del nsx'
search cancel

Unable to uninstall NSX on the ESXi host using 'del nsx'

book

Article ID: 413573

calendar_today

Updated On:

Products

VMware NSX

Issue/Introduction

- When you run 'del nsx' on the nsxcli of the ESXi host to uninstall NSX, causing the opsagent to not run and uninstall wont be completed with following error:

33937680 cli.commands.host_shared.register WARNING Error in 'nsx environment delete'. error code: 4 stdout: delete_nsx_instance_from_host.sh: INFO: NSX reset script called with argument fabric_node on nsx-esx delete_nsx_instance_from_host.sh: INFO: Run transport_node reset on ESX node % Failed to remove all host switches or logical switches delete_nsx_instance_from_host.sh: ERROR: Failed to reset nsxa app of nsx-opsagent. Please check ospagent logs for more details. stderr: ERROR: Failed to reset nsxa app of nsx-opsagent. Please check ospagent logs for more details.

- This happens when ESXi host is on 7.0.3 but NSX VIBs are installed for 6.7 version

nsx-nestdb 3.1.1.0.0-6.7.17483060 VMware VMwareCertified
nsx-netopa 3.1.1.0.0-6.7.17483060 VMware VMwareCertified
nsx-opsagent 3.1.1.0.0-6.7.17483060 VMware VMwareCertified

Environment

VMware NSX-T Data Center 

VMware vSphere ESXi 7.0.3

Cause

Since there is a mismatch in versions (ESXi version with NSX VIB version), nsxcli (del nsx) will not work in this case

Resolution

Workaround:

1. Prepare the Host

  • Place the host in Maintenance Mode to ensure no active traffic or VM dependencies.

  • Enable SSH and the ESXi Managed Object Browser (MOB).
    1. Log in to the ESXi host web interface (https://<ESXi_IP>/ui).

    2. Navigate to Manage in the left-hand navigator.

    3. Click the System tab and then select Advanced settings.

    4. Search for Config.HostAgent.plugins.solo.enableMob.

    5. Right-click the setting and select Edit option, or click the Edit button, and set the value to true.

2. Delete Active NSX Ports (VTEPs and Logical Ports): 

  • List existing ports on the N-VDS: net-dvs -l | grep -E "vdrPort|vtep|spfPort"

  • Delete each identified port: net-dvs -D -p <port_id> <switch_name> (Note: Replace <port_id> with the ID found in the list and <switch_name> with your N-VDS name, e.g., nvds.0).

3. Remove the N-VDS via MOB.
*Since the CLI might fail to delete a "busy" switch, use the Host MOB to force the removal:

  • Navigate to: https://<esx_ip>/mob/moid=ha-hostdvsmanager&vmodl=1 

  • Locate and click on the method removeDistributedVirtualSwitch.

  • In the value field, enter the name of your N-VDS (e.g., nvds.0) and click Invoke Method.

4. Manually Remove NSX VIBs.
*Run the following commands in sequence to remove the software packages:

  • Remove Primary NSX Components:

    esxcli software vib remove -n=nsx-adf -n=nsx-context-mux -n=nsx-exporter -n=nsx-host -n=nsx-monitoring -n=nsx-netopa -n=nsx-opsagent -n=nsx-proxy -n=nsx-python-logging -n=nsx-python-utils -n=nsxcli -n=nsx-sfhc -n=nsx-platform-client -n=nsx-cfgagent -n=nsx-mpa -n=nsx-nestdb -n=nsx-python-gevent -n=nsx-python-greenlet -n=nsx-python-protobuf -n=nsx-vdpi -n=nsx-ids

  • Remove Datapath Components (requires --no-live-install):

    esxcli software vib remove -n=nsx-esx-datapath --no-live-install

  • Remove Shared Libraries:

    esxcli software vib remove -n=vsipfwlib -n=nsx-cpp-libs -n=nsx-proto2-libs -n=nsx-shared-libs

    ***Note: If any VIB fails to remove, append --force --no-live-install to the end of that specific command.

5. Finalize

  • Reboot the ESXi host to clear remaining kernel modules from memory.