Dokploy/dokploy · error · TRPCError

CONFLICT

CONFLICT

Error message

Service with this 'AppName' already exists

What it means

createMysql builds a namespaced app name via buildAppName('mysql', appName) and validates uniqueness with validUniqueServerAppName across the target server. If an app (any service) already uses that name on that server, a CONFLICT is thrown before any DB insert.

Source

Thrown at packages/server/src/services/mysql.ts:25

} from "@dokploy/server/db/schema";
import { generatePassword } from "@dokploy/server/templates";
import { buildMysql } from "@dokploy/server/utils/databases/mysql";
import { pullImage } from "@dokploy/server/utils/docker/utils";
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
import { TRPCError } from "@trpc/server";
import { eq, getTableColumns } from "drizzle-orm";
import { quote } from "shell-quote";
import type { z } from "zod";
import { validUniqueServerAppName } from "./project";

export type MySql = typeof mysql.$inferSelect;

export const createMysql = async (input: z.infer<typeof apiCreateMySql>) => {
	const appName = buildAppName("mysql", input.appName);

	const valid = await validUniqueServerAppName(appName);
	if (!valid) {
		throw new TRPCError({
			code: "CONFLICT",
			message: "Service with this 'AppName' already exists",
		});
	}

	const newMysql = await db
		.insert(mysql)
		.values({
			...input,
			databasePassword: input.databasePassword
				? input.databasePassword
				: generatePassword(),
			databaseRootPassword: input.databaseRootPassword
				? input.databaseRootPassword
				: generatePassword(),
			appName,
		})
		.returning()

View on GitHub (pinned to 546686ea35)

Solutions

  1. Choose a different appName for the new mysql service
  2. List existing services on that server to confirm the collision and reuse or delete the existing one
  3. Make automation idempotent: check existence by appName before creating
  4. Guard against double submission in the UI

Example fix

// before
await createMysql({ appName: "db", serverId });
// after
const exists = (await listMySql(serverId)).some(m => m.appName.includes("mysql-db"));
if (!exists) await createMysql({ appName: "db", serverId });
Defensive patterns

Strategy: validation

Validate before calling

const dup = (await listServices(serverId)).some(s => s.appName === buildName("mysql", appName));
if (dup) throw new Error("appName already in use on this server");

Try / catch

try { await createMysql(input); } catch (e) { if (e instanceof TRPCError && e.code === "CONFLICT") promptRename(); else throw e; }

Prevention

When it happens

Trigger: Creating a mysql service with an appName that collides with an existing mysql/postgres/redis/app on the same server; creating the same service twice because the first request was double-submitted.

Common situations: Double-clicking 'Create' in the UI, retrying after a timeout when the first create actually succeeded, re-running a terraform/script without idempotency checks.

Related errors


AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27). Data as JSON: /api/errors/0946e99251caa578. Report an issue: GitHub.