Dokploy/dokploy · error · TRPCError
CONFLICT
CONFLICT
Error message
Port ${input.externalPort} is already in use by ${portCheck.conflictingContainer} What it means
CONFLICT thrown during postgres update when input.externalPort is set and checkServiceSettingsPort/checkPortInUse detects another container already bound to that host port (optionally on a specific server). Docker cannot bind two containers to the same host port.
Source
Thrown at apps/dokploy/server/api/routers/postgres.ts:209
resourceName: postgres.appName,
});
return postgres;
}),
saveExternalPort: protectedProcedure
.input(apiSaveExternalPortPostgres)
.mutation(async ({ input, ctx }) => {
await checkServicePermissionAndAccess(ctx, input.postgresId, {
service: ["create"],
});
const postgres = await findPostgresById(input.postgresId);
if (input.externalPort) {
const portCheck = await checkPortInUse(
input.externalPort,
postgres.serverId || undefined,
);
if (portCheck.isInUse) {
throw new TRPCError({
code: "CONFLICT",
message: `Port ${input.externalPort} is already in use by ${portCheck.conflictingContainer}`,
});
}
}
await updatePostgresById(input.postgresId, {
externalPort: input.externalPort,
});
await deployPostgres(input.postgresId);
await audit(ctx, {
action: "update",
resourceType: "service",
resourceId: postgres.postgresId,
resourceName: postgres.appName,
});
return postgres;
}),View on GitHub (pinned to 546686ea35)
Solutions
- Choose a different externalPort not listed as in use
- Stop or reconfigure the conflicting container named in the message
- If the conflict is with the same Postgres's old deployment, ensure the old container is fully removed before changing the port
Example fix
// before
await api.postgres.update.mutate({ postgresId, externalPort: 5432 });
// after
await api.postgres.update.mutate({ postgresId, externalPort: 5433 }); Defensive patterns
Strategy: validation
Validate before calling
const check = await checkPortInUse(externalPort, serverId);
if (check.isInUse) throw new Error(`Port taken by ${check.conflictingContainer}`); Try / catch
catch (e) { if (e.data?.code === 'CONFLICT') autoIncrementPortAndRetry(); } Prevention
- Let Dokploy auto-assign ports when possible
- Maintain a port registry per server to avoid collisions
When it happens
Trigger: Updating a Postgres to an externalPort already published by another container (conflictingContainer name is included in the message); also triggers if the port is used outside Docker on the selected server.
Common situations: Reusing a port exposed by another database/app; moving a Postgres to a server where the port is taken; port value left over from a copied config.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/614895ccf4c4adb5.
Report an issue: GitHub.