An error have occured: Deployment not found
To Reproduce
- use Dokploy v0.27.0
- Create an app, Gitlab provider .. add env whatever,
- update to new version v0.27.1
- try to deploy your app again.
- you'll probably see the issue
Current vs. Expected behavior
I have deployed applications that were working just fine on version v0.27.0. After recent update, I cannot deploy them. I even had webhooks working just fine before, but now both webhook / manual deployment get me the following errors
Error [TRPCError]: Deployment not found
at async XP.autorun [as processFn] (dist/server.mjs:1:889) {
code: 'BAD_REQUEST'
}
Error Error [TRPCError]: Error creating the deployment
at async XP.autorun [as processFn] (dist/server.mjs:1:889) {
code: 'BAD_REQUEST'
}
Error [TRPCError]: Deployment not found
at async XP.autorun [as processFn] (dist/server.mjs:1:889) {
code: 'BAD_REQUEST'
}
Error Error [TRPCError]: Error creating the deployment
at async XP.autorun [as processFn] (dist/server.mjs:1:889) {
code: 'BAD_REQUEST'
}
Expected behavior
app to deploy as normal as it should be
Provide environment information
OS:
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
`
Dokploy : v0.27.1
Which area(s) are affected? (Select all that apply)
Application
Are you deploying the applications where Dokploy is installed or on a remote server?
Same server where Dokploy is installed
Additional context
No response
Will you send a PR to fix it?
Maybe, need help
same problem
same here , it happens with github application private repos
Got the same issue.
A temporary solution is to delete all recently failed deployments and then manually deploy again
All my applications are from GitLab, and my entire GitLab is private (Self-Hosted).. so maybe that is the issue ???
The weird thing is that it didn't happen for all my apps, just few of them at random.
Thanks @lightumcc, I had the same problem and your suggested workaround fixed it
this is not a workaround , every time we push to deployment it breaks , and we have to delete the automated deployment and manually deploy it
This is only happening with gitlab?
@Siumauricio Github as well
Just to understand, have you used the delete deployment functionality while the build is running?
If you have the exact steps to reproduce the issue would be great, the steps suggested above work well for me.
@Siumauricio for me dokploy it linked to github repo, on push to main branch , once I push it fails immediately, however when I delete the failed deployment and manually deploy it works and it actually picks-up the github commit message , was working fine the for over a year now only when updated to 27.1 , it broke
Just to understand, have you used the delete deployment functionality while the build is running?
Possibly .. I don't remember, I might've done it with one or two.. but not all the failing ones.
If you have the exact steps to reproduce the issue would be great, the steps suggested above work well for me.
I would've gladly mentioned the extract reproducible steps, unfortunately, the only thing that I did was upgrading from v0.27.0 to v0.27.1 while always of course using private self-hosted GitLab repos.
Problem is, I have other applications, same GitLab repo, same configs ... but didn't fail when manually or automatically deployed.
logs shows:
Error [TRPCError]: Deployment not found
at async XP.autorun [as processFn] (dist/server.mjs:1:889) {
code: 'BAD_REQUEST'
}
Error Error [TRPCError]: Error creating the deployment
at async XP.autorun [as processFn] (dist/server.mjs:1:889) {
code: 'BAD_REQUEST'
}
Error [ExecError]: Command execution failed: Command failed: pkill -2 -f "docker build"
at m (.next/server/chunks/8192.js:42:1740)
at async q (.next/server/chunks/2035.js:124:2501)
at async (.next/server/chunks/2035.js:1:22764) {
command: 'pkill -2 -f "docker build"',
stdout: '',
stderr: '',
exitCode: null,
originalError: Error: Command failed: pkill -2 -f "docker build"
at ignore-listed frames {
code: null,
killed: false,
signal: 'SIGINT',
cmd: 'pkill -2 -f "docker build"',
stdout: '',
stderr: ''
},
serverId: undefined
}
@Siumauricio I have another application that was working all good, after updating the branch in General / Deploy I start facing same issue on every single deploy
same
I think this has been fixed in version 0.28.1 (latest update). probably because they revert the API in commit : https://github.com/Dokploy/dokploy/commit/9507745cc0ae251bfdafb5e2afc826be029f19f9
can anyone confirm ?
for me it still the same even with 0.28.1
Root Cause Analysis
I just hit this on v0.28.2 with a GitHub-sourced app (Dockerfile build type). I spent time digging into the Dokploy source code and I believe I found the exact root cause. It's a self-reinforcing error loop in createDeployment() that makes the app permanently undeployable once it enters the error state.
The bug step by step
1. Initial failure (transient)
createDeployment() in packages/server/src/services/deployment.ts calls removeLastTenDeployments() before creating the deployment record. If anything fails during this function — a filesystem error, a race condition when two webhooks fire simultaneously, a missing log file — execution falls into the catch block.
2. The catch block poisons the state
The catch block does two things that make recovery impossible:
catch (error) {
// Creates a NEW deployment record with status: "error" and logPath: ""
await db.insert(deployments).values({
applicationId: deployment.applicationId,
status: "error",
logPath: "", // <-- THIS IS THE POISON
errorMessage: `An error have occured: ${error instanceof Error ? error.message : error}`,
...
});
// Locks the application in error state
await updateApplicationStatus(application.applicationId, "error");
throw new TRPCError({ code: "BAD_REQUEST", message: "Error creating the deployment" });
}
3. Next deploy attempt hits the same wall
On the next deploy attempt, createDeployment() calls removeLastTenDeployments() again. This function iterates old deployments and calls removeDeployment() for each one. When it hits the poisoned record (with logPath: ""):
removeDeployment()deletes the DB record, then runsrm -f ${deployment.logPath}— which with an empty string becomesrm -fwith no argument (or withpath.join("")→".")- If this fails, or if another concurrent deployment already deleted it,
removeDeployment()throws"Deployment not found" - This propagates up to
createDeployment()'s catch block - The catch block creates ANOTHER poisoned deployment record with
logPath: "" applicationStatusis set to"error"again- The cycle repeats on every deploy attempt
Why some apps break and others don't
The initial trigger is transient and race-condition dependent. In my case, I had two apps in the same project with identical configs (same GitHub provider, same branch, same Dockerfile build type). The API app deployed fine. The web app got unlucky — likely a race condition from rapid webhook triggers — and entered the loop.
The actual errors in sequence
Every failed deploy produces this exact pattern in Dokploy logs:
Error [TRPCError]: Deployment not found ← removeDeployment() failing on cleanup
Error [TRPCError]: Error creating the deployment ← createDeployment() catch block
And creates a deployment record in the DB with:
status: "error", logPath: "", errorMessage: "An error have occured: Deployment not found"
Additional bug: copy-paste error in removeDeployment
removeDeployment() has a wrong fallback error message in its catch block:
catch (error) {
const message = error instanceof Error ? error.message : "Error creating the deployment";
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Should be "Error removing the deployment"
}
This makes logs confusing because a deletion failure reports as a creation failure.
No recovery mechanism exists
applicationStatus = 'error'is set in the catch block but nothing ever resets it on retry- The startup cleanup (
initCancelDeployments) only handles"running"→"cancelled", not"error"→"idle" - The deploy/redeploy router procedures don't check
applicationStatus, so jobs are queued but always fail inside the worker
How to reproduce
- Create an application with GitHub/GitLab provider
- Deploy it successfully at least once
- Manually insert a poisoned deployment record:
INSERT INTO deployment ("deploymentId", "applicationId", "title", "status", "logPath", "errorMessage", "startedAt", "finishedAt") VALUES (gen_random_uuid()::text, '<APP_ID>', 'Test', 'error', '', 'An error have occured: test', NOW(), NOW()); - Make sure the app has 10+ deployments total (so
removeLastTenDeploymentstriggers) - Try to deploy — it will fail with "Deployment not found" / "Error creating the deployment" and never recover
Workaround
What actually fixes it (confirmed on v0.28.2):
-- Delete all poisoned error deployments for the affected app
DELETE FROM deployment
WHERE "applicationId" = '<APP_ID>'
AND "status" = 'error'
AND "logPath" = '';
-- Reset application status
UPDATE application
SET "applicationStatus" = 'done'
WHERE "applicationId" = '<APP_ID>';
Then redeploy manually.
Suggested fixes
-
Don't create error deployment records in
createDeployment()'s catch block — or at minimum, don't create them withlogPath: "". The error record with empty logPath is what poisons subsequent cleanup cycles. -
Make
removeDeployment()gracefully handle already-deleted deployments — returnnullinstead of throwing when the deployment doesn't exist. Cleanup should be idempotent. -
Add a guard in
removeLastTenDeployments()— skip deployments that have emptylogPathor wrap individualremoveDeployment()calls in try-catch so one failed cleanup doesn't abort the entire operation. -
Fix the copy-paste error in
removeDeployment()'s catch block ("Error creating the deployment"→"Error removing the deployment"). -
Add a recovery mechanism — either reset
applicationStatusbefore each deploy attempt, or add a "retry/reset" button in the UI that clears the error state.
Hope this helps track down the fix! Happy to help test a patch if needed.