{"record":{"id":"b060bcfc5b9a2fbf","repo":"vxcontrol/pentagi","slug":"failed-to-create-network-s-w","errorCode":null,"errorMessage":"failed to create network %s: %w","messagePattern":"failed to create network (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/docker/client.go","lineNumber":1327,"sourceCode":"}\n\n// ensureDockerNetwork verifies that a docker network with the given name exists;\n// if it does not, it attempts to create it.\n// Special case: \"host\" network mode is built-in and doesn't need creation.\nfunc ensureDockerNetwork(ctx context.Context, cli *client.Client, name string) error {\n\tif name == \"\" || name == \"host\" {\n\t\treturn nil\n\t}\n\n\tif _, err := cli.NetworkInspect(ctx, name, client.NetworkInspectOptions{}); err == nil {\n\t\treturn nil\n\t}\n\n\t_, err := cli.NetworkCreate(ctx, name, client.NetworkCreateOptions{\n\t\tDriver: \"bridge\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create network %s: %w\", name, err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":1309,"sourceCodeEnd":1332,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/docker/client.go#L1309-L1332","documentation":"Returned when creating the Docker bridge network for a flow fails via cli.NetworkCreate. The network name is embedded in the message and the daemon error is wrapped so the root cause remains inspectable.","triggerScenarios":"NetworkCreate fails because a network with the same name already exists with conflicting settings, the address pool is exhausted, or the daemon's bridge/networking subsystem is broken.","commonSituations":"Leftover network from a previous crashed run; default Docker address pool (default 31 /16 networks) exhausted by many flows/compose stacks; kernel/iptables issues after host updates; daemon misconfiguration of the bridge driver.","solutions":["Check if a network with the same name exists (`docker network ls`) and remove the stale one (`docker network rm`)","Free address space: remove unused networks (`docker network prune`) or configure larger default-address-pools in daemon.json","Restart the Docker daemon to rebuild bridge/iptables state","Check the wrapped daemon error for the precise cause (conflict vs pool vs driver)"],"exampleFix":"// before\n_, err := cli.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: \"bridge\"})\n// after\n_, err := cli.NetworkCreate(ctx, name, client.NetworkCreateOptions{Driver: \"bridge\"})\nif err != nil && strings.Contains(err.Error(), \"already exists\") {\n    return nil // or inspect/reuse the existing network\n}","handlingStrategy":"fallback","validationCode":"// pre-check\ndocker network ls --format '{{.Name}}' | grep -qx <name> && docker network rm <name>","typeGuard":"func isNetworkCreateError(err error) bool { return strings.Contains(err.Error(), \"failed to create network\") }","tryCatchPattern":"if err := dc.ensureNetwork(ctx, name); err != nil {\n    if strings.Contains(err.Error(), \"already exists\") {\n        // reuse existing network\n    } else {\n        log.WithError(err).Error(\"network create failed\")\n    }\n}","preventionTips":["Prune stale networks regularly (`docker network prune`)","Configure larger default-address-pools in daemon.json for many-flow workloads","Name networks deterministically per flow so stale ones can be detected/reused","Restart the daemon after host networking/kernel updates"],"tags":["docker","network","bridge"],"backgroundTag":"docker-network-create-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}