Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error input: Inserting Postgres database
What it means
Catch-all BAD_REQUEST in createPostgres: the underlying database insert (or setup logic) threw a non-TRPCError. The original error is attached as cause. Common causes are Drizzle ORM constraint violations (duplicate appName/postgresId), invalid enum values, or DB connectivity issues.
Source
Thrown at apps/dokploy/server/api/routers/postgres.ts:121
serviceId: newPostgres.postgresId,
serviceType: "postgres",
volumeName: `${newPostgres.appName}-data`,
mountPath: mountPath,
type: "volume",
});
await audit(ctx, {
action: "create",
resourceType: "service",
resourceId: newPostgres.postgresId,
resourceName: newPostgres.appName,
});
return newPostgres;
} catch (error) {
if (error instanceof TRPCError) {
throw error;
}
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error input: Inserting Postgres database",
cause: error,
});
}
}),
one: protectedProcedure
.input(apiFindOnePostgres)
.query(async ({ input, ctx }) => {
await checkServiceAccess(ctx, input.postgresId, "read");
const postgres = await findPostgresById(input.postgresId);
if (
postgres.environment.project.organizationId !==
ctx.session.activeOrganizationId
) {
throw new TRPCError({
code: "UNAUTHORIZED",View on GitHub (pinned to 546686ea35)
Solutions
- Inspect error.cause for the real driver error (unique constraint, FK, connection refused)
- If it's a duplicate appName, choose a different name or fully remove the old record
- Run Dokploy migrations / restart if the DB schema is stale
- Retry after confirming the Dokploy internal database is healthy
Defensive patterns
Strategy: try-catch
Try / catch
try {
await api.postgres.create.mutate(input);
} catch (e) {
const cause = e.cause ?? e.data?.cause;
if (String(cause).includes('unique')) throw new Error('Name already in use');
throw e;
} Prevention
- Always inspect error.cause for the real DB error
- Use unique app names per instance
When it happens
Trigger: Any exception during postgres creation after the auth checks — duplicate unique key (appName already used), malformed input that passed Zod but violates DB constraints, or the database being unreachable.
Common situations: Recreating a Postgres with the same app name after an incomplete deletion; DB schema out of sync after a Dokploy upgrade; transient Postgres downtime on the control plane.
Understand the failure class
Background: BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries — this error's family across 8 libraries.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/fa15a6bd56d6c695.
Report an issue: GitHub.