Dokploy/dokploy · error · TRPCError
INTERNAL_SERVER_ERROR
INTERNAL_SERVER_ERROR
Error message
Failed to create network
What it means
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.
Source
Thrown at packages/server/src/services/network.ts:227
if (!input.serverId) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Server is required",
});
}
}
const created = await db.transaction(async (tx) => {
const [row] = await tx
.insert(network)
.values({
...input,
organizationId,
})
.returning();
if (!row) {
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Failed to create network",
});
}
await createDockerNetworkFromRow(row);
return row;
});
return created;
};
const createDockerNetworkFromRow = async (row: typeof network.$inferSelect) => {
const ipam = row.ipam ?? {};
const ipamConfig = (ipam.config ?? [])
.map((c) => {
const entry: Record<string, string> = {};View on GitHub (pinned to 546686ea35)
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
Defensive patterns
Strategy: retry
Try / catch
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; } Prevention
- Keep migrations in sync with the network table schema
- Use direct (non-pooled) DB connections for admin writes if RETURNING misbehaves
When it happens
Trigger: 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.
Common situations: Flaky DB connection during creation, migrations not applied so the insert shape mismatches, pooled connections stripping RETURNING results.
Related errors
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/005babadd42e3fe2.
Report an issue: GitHub.