{"record":{"id":"005babadd42e3fe2","repo":"Dokploy/dokploy","slug":"internal-server-error-005bab","errorCode":"INTERNAL_SERVER_ERROR","errorMessage":"Failed to create network","messagePattern":"Failed to create network","errorType":"exception","errorClass":"TRPCError","httpStatus":500,"severity":"error","filePath":"packages/server/src/services/network.ts","lineNumber":227,"sourceCode":"\t\tif (!input.serverId) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\tmessage: \"Server is required\",\n\t\t\t});\n\t\t}\n\t}\n\n\tconst created = await db.transaction(async (tx) => {\n\t\tconst [row] = await tx\n\t\t\t.insert(network)\n\t\t\t.values({\n\t\t\t\t...input,\n\t\t\t\torganizationId,\n\t\t\t})\n\t\t\t.returning();\n\n\t\tif (!row) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: \"INTERNAL_SERVER_ERROR\",\n\t\t\t\tmessage: \"Failed to create network\",\n\t\t\t});\n\t\t}\n\n\t\tawait createDockerNetworkFromRow(row);\n\n\t\treturn row;\n\t});\n\n\treturn created;\n};\n\nconst createDockerNetworkFromRow = async (row: typeof network.$inferSelect) => {\n\tconst ipam = row.ipam ?? {};\n\tconst ipamConfig = (ipam.config ?? [])\n\t\t.map((c) => {\n\t\t\tconst entry: Record<string, string> = {};","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/network.ts#L209-L245","documentation":"After db.insert(network).values(...).returning(), the code throws INTERNAL_SERVER_ERROR 'Failed to create network' if no row came back. A successful INSERT always returns a row, so this indicates the insert failed at the driver level or returned an empty set — an abnormal database state rather than a user-input problem.","triggerScenarios":"Database connectivity loss mid-statement, a misbehaving RETURNING clause behind a connection pooler (pgbouncer transaction mode), or schema drift (missing columns) causing driver-level silent failure.","commonSituations":"Flaky DB connection during creation, migrations not applied so the insert shape mismatches, pooled connections stripping RETURNING results.","solutions":["Check DB logs for the failed INSERT and apply pending migrations","Verify the connection string (direct vs pooled) works with RETURNING","Retry the create — transient failures are common","Confirm the network table schema matches the inserted columns"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await createNetwork(input, orgId); } catch (e) { if (e instanceof TRPCError && e.code === \"INTERNAL_SERVER_ERROR\" && e.message === \"Failed to create network\") await backoffRetry(2); else throw e; }","preventionTips":["Keep migrations in sync with the network table schema","Use direct (non-pooled) DB connections for admin writes if RETURNING misbehaves"],"tags":["network","database","insert"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}