# Unable to Delete Network Host Config from UI

## Problem

Unable to delete network host config from the UI, even if the host is not using it.

## Environment

* Private Cloud Director Virtualization - till 2025.4-497
* Self-Hosted Private Cloud Director Kubernetes - till 2025.4-497
* Component: Blueprint

## Cause

The host configuration was previously associated with a host that has since been decommissioned. However, a **stale mapping entry** remains between the host and the host configuration in the `host_to_hostconfig_map` table of the Resource Manager database.

This issue is tracked under bug **PCD-407** and is now fixed in PCD 2025.6-151 and later releases, which prevent new stale mappings from being created.

{% hint style="warning" %}
Existing stale entries from earlier versions will persist after the upgrade; it's recommended to follow the steps mentioned in the Workaround to delete the stale entries.
{% endhint %}

## Workaround

* Retrieve the token:

```bash
token=$(openstack token issue -f value -c id)
```

* Get the list of host configs:

```bash
curl -s -X GET   -H "X-Auth-Token: $token"   https://<PCD_FQDN>/resmgr/v2/hostconfigs | jq '.[] | {id, name}'

# Sample Output:
{
  "id": "[HOSTCONFIG_ID_1]",
  "name": "[HOSTCONFIG_NAME_1]"
}
{
  "id": "[HOSTCONFIG_ID_2]",
  "name": "[HOSTCONFIG_NAME_2]"
}
{
  "id": "[HOSTCONFIG_ID_3]",
  "name": "[HOSTCONFIG_NAME_3]"
}
```

* Get the list of hosts that use the host config that needs to be deleted:

```bash
curl -s -X GET   -H "X-Auth-Token: $token"   https://<PCD_FQDN>/resmgr/v2/hosts   | jq -c '.[] | select(.hostconfig_id == "<HOSTCONFIG_ID>") | {id, hostname: .info.hostname, hostconfig_id}'

# Sample Output:
{
  "id": "[HOST_ID_1]",
  "hostname": "[HOSTNAME_1]",
  "hostconfig_id": "[HOSTCONFIG_ID]"
}
{
  "id": "[HOST_ID_2]",
  "hostname": "[HOSTNAME_2]",
  "hostconfig_id": "[HOSTCONFIG_ID]"
}
```

* Delete the stale host config mapping. Run below for each `[HOST_ID]`returned in the output of the command executed in the above output

```bash
curl -s -X DELETE   -H "X-Auth-Token: $token"   "https://<PCD_FQDN>/resmgr/v2/hosts/<HOST_ID>/hostconfig/<HOSTCONFIG_ID>"
```

* Delete the host Configuration after removing all the mappings

```bash
curl -s -X DELETE -H "X-Auth-Token: $token" "https://<PCD_FQDN>/resmgr/v2/hostconfigs/<HOSTCONFIG_ID>"
```

## Validation

Check the UI to confirm that the previously stale host configuration no longer appears.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://platform9.com/kb/pcd/generic/unable-to-delete-network-host-config-from-ui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
