{"record":{"id":"0d0242d762a788c4","repo":"nextcloud/all-in-one","slug":"could-not-create-the-nextcloud-aio-network-detai","errorCode":null,"errorMessage":"Could not create the nextcloud-aio network: {details}","messagePattern":"Could not create the nextcloud-aio network: (.+?)","errorType":"exception","errorClass":"\\Exception","httpStatus":500,"severity":"critical","filePath":"php/src/Docker/DockerActionManager.php","lineNumber":920,"sourceCode":"        if ($createNetwork) {\n            $url = $this->BuildApiUrl('networks/create');\n            try {\n                $this->sendHttpRequest(\n                    'POST',\n                    $url,\n                    [\n                        'json' => [\n                            'Name' => $network,\n                            'CheckDuplicate' => true,\n                            'Driver' => 'bridge',\n                            'Internal' => false,\n                        ]\n                    ]\n                );\n            } catch (RequestException $e) {\n                // 409 is undocumented and gets thrown if the network already exists.\n                if ($e->getCode() !== 409) {\n                    throw new \\Exception(\"Could not create the nextcloud-aio network: \" . $e->getResponse()?->getBody()->getContents());\n                }\n            }\n        }\n\n        $url = $this->BuildApiUrl(\n            sprintf('networks/%s/connect', $network)\n        );\n        $jsonPayload = ['Container' => $id];\n        if ($alias !== '') {\n            $jsonPayload['EndpointConfig'] = ['Aliases' => [$alias]];\n        }\n\n        try {\n            $this->sendHttpRequest(\n                'POST',\n                $url,\n                [\n                    'json' => $jsonPayload","sourceCodeStart":902,"sourceCodeEnd":938,"githubUrl":"https://github.com/nextcloud/all-in-one/blob/6b788eec5e61733cf03ed380a3572e43ae3f11ce/php/src/Docker/DockerActionManager.php#L902-L938","documentation":"POST /networks/create for the nextcloud-aio bridge network failed with a RequestException whose code is NOT 409 — 409 (network already exists) is deliberately tolerated as success, making creation idempotent. The daemon's error body is embedded. After creation (or tolerance) the container is connected to this network, so a failure here blocks every container attach.","triggerScenarios":"Docker address-pool exhaustion ('all predefined address pools have been fully subnetted') when too many networks exist; daemon/network-driver errors; invalid network configuration in daemon.json; a same-name network in a broken state that 409 does not cover.","commonSituations":"Hosts running many compose projects or containers exhausting the default 172.17-31.x space; leftover half-created networks; custom default-address-pools config too small.","solutions":["List and remove leftovers: docker network ls | grep nextcloud-aio then docker network rm <name>, and retry","If pools are exhausted: docker network prune unused networks, or extend default-address-pools in /etc/docker/daemon.json and restart docker","Check the daemon logs (journalctl -u docker) for the underlying create failure","Verify daemon.json network settings are valid before restarting the daemon"],"exampleFix":"// before: create and only tolerate 409\n// after: pre-check existence, then create — fully idempotent\ntry {\n    $docker->sendHttpRequest('POST', $docker->BuildApiUrl('networks/create'), [\n        'json' => ['Name' => $network, 'CheckDuplicate' => true, 'Driver' => 'bridge', 'Internal' => false]\n    ]);\n} catch (RequestException $e) {\n    if ($e->getCode() !== 409) { throw $e; } // already exists → fine\n}","handlingStrategy":"fallback","validationCode":"// Check existence first and reuse the existing network instead of creating\n$nets = json_decode($docker->sendHttpRequest('GET', $docker->BuildApiUrl('networks'))->getBody(), true) ?: [];\n$exists = in_array('nextcloud-aio', array_column($nets, 'Name'), true);\nif (!$exists) {\n    $docker->sendHttpRequest('POST', $docker->BuildApiUrl('networks/create'), [\n        'json' => ['Name' => 'nextcloud-aio', 'CheckDuplicate' => true, 'Driver' => 'bridge', 'Internal' => false]\n    ]);\n}\n// proceed to networks/{name}/connect either way","typeGuard":null,"tryCatchPattern":"try {\n    createNetworkAndConnect($id, $alias);\n} catch (\\Exception $e) {\n    if (str_contains($e->getMessage(), 'Could not create the nextcloud-aio network')) {\n        // address-pool exhaustion is the usual cause: report prune/daemon.json guidance verbatim\n        reportNetworkExhaustion($e->getMessage());\n    }\n    throw $e;\n}","preventionTips":["Tolerate 409 (already exists) exactly as the library does — network creation must stay idempotent","Prune unused docker networks regularly on hosts running many compose projects; default address pools exhaust silently","Size default-address-pools in /etc/docker/daemon.json for your network count before deploying"],"tags":["php","docker","networks","daemon-api","address-pool"],"backgroundTag":"docker-network-create-failed","analyzedSha":"6b788eec5e61733cf03ed380a3572e43ae3f11ce","analyzedAt":"2026-08-21T05:47:24.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}