Solution
If a deployment or runbook run is stuck in Cancelling or Running and other deployments are queued behind it, first check that it isn't just waiting (see Check whether the task is waiting).
If it's stuck, cancel it. If it's still Cancelling after 10 minutes, select Abandon on the task page (Octopus Server 2026.4.2686 and later). Octopus marks the task as Canceled, and the queued deployments start.
If there's no Abandon button and you use self-hosted Octopus Server, restart the Octopus Server service. If that doesn't clear it, or you use Octopus Cloud, contact Octopus Support.
Abandoning a task doesn't stop its script on the deployment target, so check the target afterward.
Cause
A deployment queued behind the stuck task shows this on its task page, with the stuck task listed under Blocking Tasks:
This task is queued behind 1 other task.
The stuck task shows Cancelling or Running, with Cancel grayed out. If someone has canceled it, the task log shows:
Requesting cancellation...
Octopus runs one deployment at a time per project, environment, and tenant. A task in Cancelling or Running still counts as in progress. Later deployments of that project to that environment wait behind it, including ones started by a lifecycle or trigger. It also uses a task cap slot.
A canceled task normally finishes in under a minute, even if the script is hung or the Tentacle is unreachable. It stays stuck when Octopus Server can't finish recording the cancellation or the end of the deployment.
Diagnosis and fix
Check whether the task is waiting
Queued behind another task: The task under Blocking Tasks is the one to look at. You can also get it from the API:
GET /api/<SpaceId>/tasks/<TaskId>/queued-behind
Each item is a task this one is waiting for. A stuck task shows a State of Cancelling or Executing, and a StartTime well in the past. Trimmed example:
{
"ItemType": "Task",
"TotalResults": 1,
"Items": [
{
"Id": "ServerTasks-449",
"Description": "Deploy My Project release 1.0.1 to Production",
"State": "Cancelling",
"Completed": "Cancelling...",
"QueueTime": "2026-11-19T01:44:30.658+00:00",
"StartTime": "2026-11-19T01:45:45.294+00:00",
"ServerNode": "OctopusServerNodes-OctopusServer",
"HasBeenPickedUpByProcessor": true,
"IsCompleted": false,
"Links": {
"Web": "/app#/Spaces-1/tasks/ServerTasks-449"
}
}
]
}
Retrying a Tentacle connection: The task log shows:
An error occurred communicating with Tentacle. This action will be retried after 1 seconds. Retry attempt 1. Retries will be performed for up to 149 seconds.
Could not communicate with Tentacle after 147 seconds. No more retries will be attempted.
Octopus stops retrying after about 2.5 minutes, and a canceled task then finishes canceling. Check that the target is healthy and the Tentacle service is running.
Waiting for a script from another task on the same Tentacle: The task is Running and its log shows one of these, depending on your Tentacle version:
Waiting on another script in this task to finish as this task requires that no other Octopus scripts are executing on this target at the same time.
Waiting for the script in task ServerTasks-1234 to finish as that script requires that no other Octopus scripts are executing on this target at the same time.
Newer Tentacles may show a short code such as HknfCB in place of the task ID. An abandoned task can leave its script running and holding this lock. See Stop scripts left running on the target.
Cancel, then abandon the task
Select Cancel on the task page. It's normal for a task to stay in Cancelling for up to 2 minutes.
If it's still Cancelling after 10 minutes, an Abandon button appears next to Cancel (Octopus Server 2026.4.2686 and later). Select Abandon, then Abandon task. This can't be undone, and you need the TaskCancel permission for the task's project and environment.
The task changes to Canceled, the next queued deployment starts, and the task's error message reads:
The task was abandoned by admin after it stopped responding to cancellation. Scripts and other aspects of the process may still be running.
That message is the only record. The audit log doesn't show that the task was abandoned.
To abandon from a script, call POST /api/<SpaceId>/tasks/<TaskId>/abandon. Before the 10 minutes are up, it returns Only an execution that has been cancelling for longer than 10 minutes can be abandoned. Selecting Cancel again doesn't restart the 10 minutes.
Stop scripts left running on the target
After an abandon, or a cancel that ended because the Tentacle was unreachable, the script can keep running on the target untracked. While it runs, it can keep holding the Tentacle's script lock, so the next deployment to that target waits with Waiting for the script in task … to finish. Stopping the leftover processes releases the lock without restarting the Tentacle.
Note: For Windows and Linux deployment targets, run the commands directly on the deployment target. The Octopus Script Console task waits for the same lock.
Warning: These commands also list scripts from other deployments that are still running on the target. Only stop the processes whose start time matches the abandoned task.
Windows
A script runs as 3 processes: a PowerShell.exe started by Tentacle, Calamari.exe, and the script's own PowerShell.exe (or pwsh.exe).
-
Open PowerShell with Run as administrator. You need an administrator session to see the processes started by Tentacle.
-
List the script processes:
Get-CimInstance -ClassName Win32_Process |
Where-Object { $_.Name -eq 'Calamari.exe' -or $_.CommandLine -like '*\Octopus\Work\*' } |
Select-Object ProcessId, ParentProcessId, CreationDate, Name
The processes for one script are listed together, and each one's ParentProcessId is the ProcessId of the one before it. For example (your IDs and times will be different):
ProcessId ParentProcessId CreationDate Name
--------- --------------- ------------ ----
5840 3568 11/23/2026 5:34:03 PM powershell.exe
1484 5840 11/23/2026 5:34:07 PM Calamari.exe
2684 1484 11/23/2026 5:34:08 PM powershell.exe
The first process's ParentProcessId (3568 in the example) is Tentacle.exe. Don't stop it.
-
Find the 3 processes whose
CreationDatematches the abandoned task's start time. -
Stop them, using your own values from the
ProcessIdcolumn. With the example above, the command is:
Stop-Process -Id 2684, 1484, 5840 -Confirm
PowerShell shows each process's name and ID and asks you to confirm before it stops it.
Linux
A script runs as 3 processes: Bootstrap.sh started by Tentacle, Calamari, and the script itself, which shows as bash Bootstrap.<id>.Script.sh.
- List the script processes:
ps -eo pid,pgid,lstart,args | grep -E '[C]alamari|[B]ootstrap'
The brackets in the pattern stop grep from listing itself. For example:
221 1 Tue Nov 24 01:27:13 2026 /bin/bash /etc/octopus/Work/<id>/Bootstrap.sh …
222 222 Tue Nov 24 01:27:13 2026 /etc/octopus/Tools/Calamari.linux-x64/<version>/Calamari run-script …
236 222 Tue Nov 24 01:27:16 2026 bash Bootstrap.<id>.Script.sh …
The columns are the process ID (PID), the process group ID (PGID), the start time, and the command. Your IDs, times, and paths will be different.
-
Find the lines whose start time matches the abandoned task's start time.
-
Stop the script and anything it started, using your own
PGIDfrom theCalamariorScript.shline. The-before thePGIDtellskillto stop the whole process group. With the example above, the command is:
sudo kill -s KILL -- -222
Warning: Don't use the
PGIDfrom theBootstrap.shline (1in the example). That's the Tentacle's own process group, so killing it stops the Tentacle.
- If the
Bootstrap.shline is still listed, stop it by its ownPID. With the example above, the command is:
sudo kill 221
Kubernetes agent
Each script runs in its own pod in the agent's namespace.
- List the script pods with their project, environment, and step. Replace
<agent-namespace>with the namespace the agent is installed in:
kubectl get pods \
--namespace <agent-namespace> \
--selector octopus.com/scriptTicketId \
--output custom-columns="\
NAME:.metadata.name,\
PROJECT:.metadata.annotations.agent\.octopus\.com/project,\
ENVIRONMENT:.metadata.annotations.agent\.octopus\.com/environment,\
STEP:.metadata.annotations.agent\.octopus\.com/step,\
STARTED:.metadata.creationTimestamp,\
STATUS:.status.phase"
For example (your pod names and values will be different):
NAME PROJECT ENVIRONMENT STEP STARTED STATUS
octopus-script-08df491a-c104-1602-808e-75d8f3e7bbfc my-project production run-script 2026-11-23T04:32:16Z Running
-
Find the pod whose project, environment, step, and start time match the abandoned task.
-
Delete that pod, using your own pod name. With the example above, the command is:
kubectl delete pod octopus-script-08df491a-c104-1602-808e-75d8f3e7bbfc --namespace <agent-namespace>
Restart the Octopus Server service
On self-hosted Octopus Server, a restart usually clears a task stuck in Cancelling. It interrupts every task on that node, so plan for a quiet time. In a high availability cluster, restart only the node shown on the task page.
Octopus.Server.exe service --instance OctopusServer --restart
When the service is back, the task is Canceled with this message:
The task was in the process of being canceled, but the Octopus Server process that was executing the task was terminated before the task could be fully canceled. This task may be in an inconsistent state.
The task is still stuck after following this guide
If the task is still stuck after you've followed this guide, contact Octopus Support at support@octopus.com. Include your instance URL, the task ID (for example, ServerTasks-12345), what you're seeing, and the steps you've already tried.