Status
Confirmed defect, partially fixed. In self-hosted Octopus Server, deleting an account can fail because of a reference to it in an old release, deployment, or variable set snapshot that the account's Usage tab doesn't show. The workaround is to remove that hidden reference: delete deployments to deployment targets that have since been deleted, and remove old releases and runbook snapshots that used the account. One cause, orphaned variable set snapshots, is fixed in 2025.3.2120, 2025.4.7021, and all 2026.1 and later releases. The other causes are still open and can occur on any version.
Affected versions
This issue affects self-hosted Octopus Server. It was first reported in 2018.8.4 and has since been confirmed in 2020.5.5 and 2022.3.10807. It still occurs in current versions, because some of its causes have not been fixed.
One cause, orphaned variable set snapshots, was confirmed in 2024.4, 2025.1, and 2025.2. That cause is fixed in 2025.3.2120 (the 2025.3 stream), 2025.4.7021 (the 2025.4 stream), and all releases from 2026.1 onward. If you're on an earlier version, upgrading removes that cause, but an account can still be blocked from deletion by the causes that remain open.
Symptom
When you try to delete an account (for example, an Azure, AWS, SSH, or token account) in self-hosted Octopus Server, the deletion fails with this error:
There was a problem with your request. This account cannot be deleted as it is currently referenced by a variable. Please refer to account usage for more detail.
The account's Usage tab shows no usages, or shows nothing that explains why the account can't be deleted. In some cases the Usage tab still lists releases, even though the deployment target that used the account has been deleted.
Why it happens
This is a confirmed product defect, not a configuration mistake. When you delete an account, Octopus Server checks every place the account's ID is stored. That includes frozen variable snapshots saved with releases, runbook snapshots, and deployments. The account's Usage tab checks fewer places, so the delete can be blocked by a reference the Usage tab never shows.
Snapshots don't change after they're created. Removing the variable, deployment target, or environment that originally used the account doesn't remove the account's ID from existing snapshots. The hidden references come from three known sources:
- Deployments to a deleted deployment target. A deployment records the account used by its target. The reference stays after the target is deleted. See Accounts attached only to a deleted target can't be deleted (GitHub issue #6734).
- Orphaned variable set snapshots. A variable set snapshot can be left behind with no release or runbook snapshot that owns it. This is fixed in 2025.3.2120, 2025.4.7021, and all 2026.1 and later releases. See Orphaned variable set snapshots prevent deletion (GitHub issue #9330).
- Other references the Usage tab doesn't report. See Account references missing from the Usage tab (GitHub issue #8105).
Workaround
To delete an account that fails with "This account cannot be deleted as it is currently referenced by a variable", find and remove the hidden reference to the account. Work through these steps in order and try deleting the account again after each one.
Step 1: Upgrade if you're on an affected version
Orphaned variable set snapshots can block an account from being deleted. This cause is fixed in 2025.3.2120 (the 2025.3 stream), 2025.4.7021 (the 2025.4 stream), and all releases from 2026.1 onward. If your self-hosted Octopus Server is on an earlier version, upgrade, then try deleting the account again.
Step 2: Check the account's usages through the API
The Octopus API can return account usages that the Usage tab doesn't display, such as releases whose variables were later removed from the project. Replace Spaces-1 and Accounts-1 with your space ID and account ID, then call:
GET /api/Spaces-1/accounts/Accounts-1/usages
For any releases the response lists, either delete them or tighten the project's retention policy so they're cleaned up.
Step 3: Delete deployments to deleted deployment targets
If the account was used by a deployment target that has since been deleted, the deployments made to that target still reference the account. Delete those deployments. You don't need to delete the releases themselves.
Deleting deployments can affect automatic deployment triggers that rely on previous deployments.
Step 4: Remove old releases and runbook snapshots
Releases and runbook snapshots keep a frozen copy of the variables they were created with, including references to accounts. Deleting the variable later doesn't update these copies. To remove them, delete the releases and runbook snapshots that used the account, or tighten your retention policies so Octopus removes them for you.
Step 5: Contact Octopus Support
If an account still can't be deleted with "This account cannot be deleted as it is currently referenced by a variable" after removing the references you can find, contact Octopus Support. We can find the remaining references and help you remove them safely. Include:
- Your Octopus Server version
- The account ID
- The output of the account usages API call (
GET /api/Spaces-1/accounts/Accounts-1/usages) - Any other scripts you've already tried
Fix
There is a partial fix. One cause of "This account cannot be deleted as it is currently referenced by a variable" in self-hosted Octopus Server is orphaned variable set snapshots, and that cause is fixed. Upgrade to 2025.3.2120 or later on the 2025.3 stream, 2025.4.7021 or later on the 2025.4 stream, or any 2026.1 or later release. After upgrading, Octopus no longer leaves orphaned variable set snapshots behind when releases and runbook snapshots are deleted.
The other causes have no fix yet:
- Deployments to deployment targets that have since been deleted.
- References the Usage tab doesn't report.
Those causes can occur on any version, including the latest. If an account still can't be deleted after upgrading, use the workaround: remove the old releases, runbook snapshots, and deployments that still reference the account.
Tracking
Account references missing from the Usage tab (GitHub issue #8105)
Related
- Accounts in Octopus Deploy: the account types Octopus supports and how they're used.
- Configure lifecycle retention policies: set how many releases Octopus keeps, so old releases that still reference an account are cleaned up automatically.
- Retention policies overview: covers release, runbook, and package retention.
- PowerShell script to find where a variable value is used: search projects for an account ID and export the matches to a CSV.
- PowerShell scripts for finding variable and variable set usage: REST API scripts for other variable usage lookups.
- Accounts attached only to a deleted target can't be deleted (GitHub issue #6734): open. The workaround is to delete the deployments made to the deleted target.
- Orphaned variable set snapshots prevent deletion (GitHub issue #9330): fixed in 2025.3.2120, 2025.4.7021, and all 2026.1 and later releases.
- Account Usage doesn't show all usages (GitHub issue #4675): mostly fixed in 2019.7.0.
- Account Usage doesn't show tenant variable references (GitHub issue #5890): a related error, "This account cannot be deleted as it is being referenced as a variable by a tenant". Fixed in 2024.4.5867 and all 2025.1 and later releases.