Dokploy/dokploy · error · TRPCError

UNAUTHORIZED

UNAUTHORIZED

Error message

You need to use a server to create a Libsql

What it means

On Dokploy Cloud (or self-hosted with remoteServersOnly enabled), Libsql databases must be deployed to a designated remote server. The create procedure rejects requests that omit serverId in that mode with UNAUTHORIZED — effectively a tenancy/deployment-target policy, not a real auth failure.

Source

Thrown at apps/dokploy/server/api/routers/libsql.ts:60

	apiUpdateLibsql,
	libsql as libsqlTable,
} from "@/server/db/schema";
export const libsqlRouter = createTRPCRouter({
	create: protectedProcedure
		.input(apiCreateLibsql)
		.mutation(async ({ input, ctx }) => {
			try {
				const environment = await findEnvironmentById(input.environmentId);
				const project = await findProjectById(environment.projectId);

				await checkServiceAccess(ctx, project.projectId, "create");

				const webServerSettings = await getWebServerSettings();
				if (
					(IS_CLOUD || webServerSettings?.remoteServersOnly) &&
					!input.serverId
				) {
					throw new TRPCError({
						code: "UNAUTHORIZED",
						message: "You need to use a server to create a Libsql",
					});
				}

				if (project.organizationId !== ctx.session.activeOrganizationId) {
					throw new TRPCError({
						code: "UNAUTHORIZED",
						message: "You are not authorized to access this project",
					});
				}

				if (input.serverId) {
					const accessibleIds = await getAccessibleServerIds(ctx.session);
					if (!accessibleIds.has(input.serverId)) {
						throw new TRPCError({
							code: "UNAUTHORIZED",
							message: "You are not authorized to access this server",

View on GitHub (pinned to 546686ea35)

Solutions

  1. Pass a valid serverId that the organization can access
  2. If self-hosted and you intended local deployment, disable remoteServersOnly in web server settings
  3. Create/pick a server first, then reference its id in the create call

Example fix

// before
await api.libsql.create.mutate({ name: "db", projectId });
// after
await api.libsql.create.mutate({ name: "db", projectId, serverId });
Defensive patterns

Strategy: validation

Validate before calling

const servers = await api.server.list.query();
if (isCloudOrRemoteOnly && servers.length === 0) throw new Error("create a server first");
const serverId = servers[0]?.serverId;

Prevention

When it happens

Trigger: Creating a Libsql database without serverId while IS_CLOUD=true or webServerSettings.remoteServersOnly is set.

Common situations: Cloud users (or self-hosted admins who enabled remote-servers-only) using a client/API call written for the local-server model; frontend bug that drops the serverId field.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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