> 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/pmo/how-to/iscsi-target-deletion-failure-due-to-active-sessions.md).

# iSCSI Target Deletion Failure Due to Active Sessions

## Problem

When attempting to delete an iSCSI target in an OpenStack environment, the operation fails with the following error message:

{% tabs %}
{% tab title="Terminal" %}

```javascript
# tgt-admin --delete <target_iqn> -f

tgtadm: this target is still active
```

{% endtab %}
{% endtabs %}

This issue occurs because the iSCSI target is still active, preventing its removal. The target may be in use by active sessions, stale connections, or underlying kernel locks.

## Environment

* Platform9 Managed OpenStack - v4.0 and Higher

## Cause

The failure to delete the iSCSI target is commonly due to:

1. **Active iSCSI sessions**: The target is still being accessed by connected clients.
2. **Lingering iSCSI sessions**: Previously established connections were not properly closed.
3. **Kernel locks on the volume**: The logical volume is still being referenced.
4. **TGT service state**: The iSCSI target daemon (`tgtd`) has stale sessions preventing cleanup.

## Resolution

### **Step 1: Identify Active iSCSI Sessions**

Run the following command on the Cinder node to list active iSCSI sessions:

{% tabs %}
{% tab title="Terminal" %}

```javascript
# tgtadm --mode target --op show
```

{% endtab %}
{% endtabs %}

Look for session related to \<target\_iqn>

Check for the Active ISCSI sessions connected to the target:

{% tabs %}
{% tab title="Terminal" %}

```javascript
# tgtadm --mode connection --op show --tid=<target-id>
```

{% endtab %}
{% endtabs %}

### **Step 2: Delete the Active iSCSI Sessions**

If there are active connections, then terminate forcefully the active sessions for the target to allow its removal:

{% tabs %}
{% tab title="Terminal" %}

```javascript
# tgtadm --mode connection --op delete --tid=<target-id> --sid=<session-id> --force
```

{% endtab %}
{% endtabs %}

### **Step 3: Restart the TGT Service**

Restarting the `tgt` service helps clear stale sessions:

{% tabs %}
{% tab title="Terminal" %}

```javascript
# systemctl restart tgt
```

{% endtab %}
{% endtabs %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://platform9.com/kb/pmo/how-to/iscsi-target-deletion-failure-due-to-active-sessions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
