{"record":{"id":"6681c4d78f12d4b6","repo":"Dokploy/dokploy","slug":"conflict","errorCode":"CONFLICT","errorMessage":"Port ${port} (${name}) is already in use by ${portCheck.conflictingContainer}","messagePattern":"Port (.+?) \\((.+?)\\) is already in use by (.+?)","errorType":"exception","errorClass":"TRPCError","httpStatus":409,"severity":"error","filePath":"apps/dokploy/server/api/routers/libsql.ts","lineNumber":215,"sourceCode":"\t\t\t\t\tport: input.externalGRPCPort,\n\t\t\t\t\tname: \"externalGRPCPort\",\n\t\t\t\t\tcurrent: libsql.externalGRPCPort,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tport: input.externalAdminPort,\n\t\t\t\t\tname: \"externalAdminPort\",\n\t\t\t\t\tcurrent: libsql.externalAdminPort,\n\t\t\t\t},\n\t\t\t];\n\n\t\t\tfor (const { port, name, current } of portsToCheck) {\n\t\t\t\tif (port && port !== current) {\n\t\t\t\t\tconst portCheck = await checkPortInUse(\n\t\t\t\t\t\tport,\n\t\t\t\t\t\tlibsql.serverId || undefined,\n\t\t\t\t\t);\n\t\t\t\t\tif (portCheck.isInUse) {\n\t\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\t\tcode: \"CONFLICT\",\n\t\t\t\t\t\t\tmessage: `Port ${port} (${name}) is already in use by ${portCheck.conflictingContainer}`,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tawait updateLibsqlById(input.libsqlId, {\n\t\t\t\texternalPort: input.externalPort,\n\t\t\t\texternalGRPCPort: input.externalGRPCPort,\n\t\t\t\texternalAdminPort: input.externalAdminPort,\n\t\t\t});\n\t\t\tawait deployLibsql(input.libsqlId);\n\t\t\tawait audit(ctx, {\n\t\t\t\taction: \"update\",\n\t\t\t\tresourceType: \"service\",\n\t\t\t\tresourceId: libsql.libsqlId,\n\t\t\t\tresourceName: libsql.appName,","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/libsql.ts#L197-L233","documentation":"Before updating ports, the procedure runs checkPortInUse against the target server; if another container already binds the requested port, it throws CONFLICT naming the conflicting container. This prevents Docker port binding failures at deploy time.","triggerScenarios":"Submitting an update that changes a port (e.g. externalGRPCPort) to a value already bound by another container on the same server; the check only runs when the new port differs from the stored one.","commonSituations":"Two services configured with the same host port; leftover container from a previous deployment still holding the port; port changed to one already used by a reverse proxy or database.","solutions":["Choose a different, unused port for the field named in the message","Stop/redeploy the conflicting container named in portCheck.conflictingContainer if it is stale","Note that re-saving the same port value skips the check — ensure you actually changed the value if you expect validation to run on it"],"exampleFix":"// before\nawait api.libsql.update.mutate({ libsqlId, externalGRPCPort: 3000 }); // 3000 already used\n// after\nawait api.libsql.update.mutate({ libsqlId, externalGRPCPort: 3001 });","handlingStrategy":"fallback","validationCode":"const check = await api.docker.checkPort.query({ port, serverId });\nif (check.isInUse) pickAnotherPort();","typeGuard":null,"tryCatchPattern":"try { await update(port); } catch (e) { if (/already in use/i.test((e as Error).message)) autoIncrementPortAndRetry(); }","preventionTips":["Reserve port ranges per service type","Check ports before saving, not after"],"tags":["libsql","port-conflict","docker","conflict","trpc"],"backgroundTag":"port-already-in-use","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}