Dokploy/dokploy · error · TRPCError
INTERNAL_SERVER_ERROR
INTERNAL_SERVER_ERROR
Error message
Failed to move postgres
What it means
The move-to-environment/project flow updates the postgres row via a Drizzle update ... returning() and the result is empty, meaning no row matched postgresId — the Postgres no longer exists at move time.
Source
Thrown at apps/dokploy/server/api/routers/postgres.ts:494
targetEnvironmentId: z.string(),
}),
)
.mutation(async ({ input, ctx }) => {
await checkServicePermissionAndAccess(ctx, input.postgresId, {
service: ["create"],
});
const updatedPostgres = await db
.update(postgresTable)
.set({
environmentId: input.targetEnvironmentId,
})
.where(eq(postgresTable.postgresId, input.postgresId))
.returning()
.then((res) => res[0]);
if (!updatedPostgres) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Failed to move postgres",
});
}
await audit(ctx, {
action: "move",
resourceType: "service",
resourceId: updatedPostgres.postgresId,
resourceName: updatedPostgres.appName,
});
return updatedPostgres;
}),
rebuild: protectedProcedure
.input(apiRebuildPostgres)
.mutation(async ({ input, ctx }) => {
await checkServicePermissionAndAccess(ctx, input.postgresId, {
deployment: ["create"],View on GitHub (pinned to 546686ea35)
Solutions
- Verify the Postgres exists and its environment/project targets are valid before moving
- Retry the move with a fresh postgresId from a re-query
- Avoid concurrent delete+move operations on the same resource
Defensive patterns
Strategy: validation
Validate before calling
if (!(await api.postgres.one.query({ postgresId }))) throw new Error('Postgres missing before move'); Prevention
- Don't run concurrent move and delete operations on one resource
When it happens
Trigger: postgres.move called with a deleted postgresId, or the row is deleted concurrently (e.g. cleanup task) during the move.
Common situations: Moving a database whose project/environment was deleted first; double-submitted move where the first attempt removed state.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/3db9279f1bfc3339.
Report an issue: GitHub.