Dokploy/dokploy · warning · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Deployment is not running
What it means
Guard before killing a deployment process: if deployment.pid is null the deployment is not running, so there is nothing to cancel and the request fails with BAD_REQUEST.
Source
Thrown at apps/dokploy/server/api/routers/deployment.ts:186
.mutation(async ({ input, ctx }) => {
const deployment = await findDeploymentById(input.deploymentId);
const serviceId = deployment.applicationId || deployment.composeId;
if (serviceId) {
await checkServicePermissionAndAccess(ctx, serviceId, {
deployment: ["cancel"],
});
} else if (deployment.schedule?.serverId) {
const targetServer = await findServerById(deployment.schedule.serverId);
if (targetServer.organizationId !== ctx.session.activeOrganizationId) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You don't have access to this deployment.",
});
}
}
if (!deployment.pid) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Deployment is not running",
});
}
const command = `kill -9 ${deployment.pid}`;
if (deployment.schedule?.serverId) {
await execAsyncRemote(deployment.schedule.serverId, command);
} else {
await execAsync(command);
}
await updateDeploymentStatus(deployment.deploymentId, "error");
await audit(ctx, {
action: "cancel",
resourceType: "deployment",
resourceId: deployment.deploymentId,
});View on GitHub (pinned to 546686ea35)
Solutions
- Refresh deployment status before attempting cancel
- Treat this error as benign if the deployment just finished
- Only show Cancel when status is running and pid exists
Example fix
// before if (deployment.status === 'running') await cancel(deploymentId); // after if (deployment.status === 'running' && deployment.pid) await cancel(deploymentId);
Defensive patterns
Strategy: type-guard
Type guard
const isCancellable = (d: {pid: number | null; status: string}) => d.status === 'running' && !!d.pid; Try / catch
if (!isCancellable(deployment)) return; // nothing running await cancel(deploymentId);
Prevention
- Poll status before showing Cancel
- Treat already-finished deployments as a no-op
When it happens
Trigger: Cancelling a deployment that has already completed, failed, or never started (pid never recorded or cleared after finish).
Common situations: Race between UI 'Cancel' click and deployment finishing; polling latency showing a stale running state.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/03b55dac3e87a692.
Report an issue: GitHub.