> For the complete documentation index, see [llms.txt](https://platform9.com/kb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform9.com/kb/pcd/generic/how-to-force-remove-offline-host-from-pcd-using-api-call.md).

# How to Force Remove offline host from PCD Using API call?

## Problem

API-driven forced removal of an offline host in PCD.

## Environment

* Private Cloud Director Virtualization
* Self-Hosted Private Cloud Director Virtualization

## Procedure

1. Obtain an API token using the OpenStack CLI:

```bash
$ openstack token issue -f value -c id
```

2. Identify the Host ID of the offline host from the UI or using below api call:

```bash
$ curl -X GET \\
  -H "X-Auth-Token: <TOKEN_ID>" \\
  "https://<PCD_FQDN>/resmgr/v2/hosts" \\
  | jq '[.[] | {id, hostname: .info.hostname, responding: .info.responding}]'
```

{% code title="Sample Output" %}

```bash
$ curl -s -X GET \\
  -H "X-Auth-Token: <TOKEN_ID>" \\
  "https://[example-region1.app.pcd.platform9.com]/resmgr/v2/hosts" \\
  | jq '[.[] | {id, hostname: .info.hostname, responding: .info.responding}]'
[
  {
    "id": "[HOST_ID_1]",
    "hostname": "[HOST_NAME_1]",
    "responding": true
  },
  {
    "id": "[HOST_ID_2]",
    "hostname": "[HOST_NAME_2]",
    "responding": false
  },
]
```

{% endcode %}

3. Force Remove the Host:

{% hint style="warning" %}
The **DELETE** API operation can be perfomed by Admin users only.&#x20;

Also invoke the **DELETE** API for hosts that are **already offline or permanently unrecoverable and have no VMs or images tied to them**. Deleting a live host can create system inconsistencies—placing it in a limbo `deauthorized` state, causing it to re‑appear in inventory, corrupting metadata, or triggering erratic resource behavior.&#x20;

For active hosts, use [`deauthorize`](https://platform9.com/docs/private-cloud-director/private-cloud-director/add-hosts-Virtualized-Cluster#remove-all-roles-and-deauthorize-a-host) and [`decommission`](https://platform9.com/docs/private-cloud-director/private-cloud-director/add-hosts-Virtualized-Cluster#decommission-a-host) operations instead to ensure safe and consistent removal.
{% endhint %}

```bash
$ curl -X DELETE \\
  -H "X-Auth-Token: <TOKEN_ID>" \\
  "https://<PCD_FQDN>/resmgr/v2/hosts/<HOST_ID_2>"
```

4. Once the Host is removed, the associated compute service and network agents must be deleted.
   1. Note the ID of compute service and network agents.
   2. Delete the compute service and network agents associated to Host.

{% hint style="info" %}
Delete all the network agents configured for the affected host in this case \<HOST\_ID\_2> , listed in the output of command `openstack network agent list -c ID -c Agent_Type -c Host | grep <HOST_ID_2>`
{% endhint %}

```bash
# Note the ID of service_agents
$ openstack compute service list -c ID -c Binary -c Host | grep <HOST_ID_2>
| [COMPUTE_SERVICE_ID] | nova-compute   | [HOST_ID_2]

$ openstack network agent list -c ID -c Agent_Type -c Host | grep <HOST_ID_2>
| [NETWORK_METADATA_AGENT_ID]   | OVN Metadata agent           | [HOST_ID_2] |
| [NETWORK_CONTROLLER_AGENT_ID] | OVN Controller Gateway agent | [HOST_ID_2] |
.....

# Delete the service_agents associated to Host
$ openstack compute service delete <COMPUTE_SERVICE_ID>
$ openstack network agent delete <NETWORK_METADATA_AGENT_ID>
$ openstack network agent delete <NETWORK_CONTROLLER_AGENT_ID>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://platform9.com/kb/pcd/generic/how-to-force-remove-offline-host-from-pcd-using-api-call.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
