{"record":{"id":"226d614a6ea48a9a","repo":"coollabsio/coolify","slug":"network-already-added-to-this-server","errorCode":null,"errorMessage":"Network already added to this server.","messagePattern":"Network already added to this server\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"app/Livewire/Destination/New/Docker.php","lineNumber":82,"sourceCode":"        }\n        $this->generateName();\n    }\n\n    public function generateName(): void\n    {\n        $name = data_get($this->selectedServer, 'name', new_public_id());\n        $this->name = str(\"{$name}-{$this->network}\")->kebab();\n    }\n\n    public function submit(): mixed\n    {\n        try {\n            $this->authorize('create', $this->isSwarm ? SwarmDocker::class : StandaloneDocker::class);\n            $this->validate();\n            if ($this->isSwarm) {\n                $found = $this->selectedServer->swarmDockers()->where('network', $this->network)->first();\n                if ($found) {\n                    throw new \\Exception('Network already added to this server.');\n                } else {\n                    $docker = SwarmDocker::create([\n                        'name' => $this->name,\n                        'network' => $this->network,\n                        'server_id' => $this->selectedServer->id,\n                    ]);\n                }\n            } else {\n                $found = $this->selectedServer->standaloneDockers()->where('network', $this->network)->first();\n                if ($found) {\n                    throw new \\Exception('Network already added to this server.');\n                } else {\n                    $docker = StandaloneDocker::create([\n                        'name' => $this->name,\n                        'network' => $this->network,\n                        'server_id' => $this->selectedServer->id,\n                    ]);\n                }","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Livewire/Destination/New/Docker.php#L64-L100","documentation":"When creating a Docker destination for a Swarm server, Coolify refuses duplicate network names per server: it checks selectedServer->swarmDockers() for the same network name and throws before creating the SwarmDocker row.","triggerScenarios":"Submitting a network name that already exists as a Swarm destination on the selected server - e.g. the default `coolify` network registered during onboarding, or re-submitting a network added in another tab.","commonSituations":"Re-adding the default network; stale form state after a previous submit; multiple admins adding networks concurrently.","solutions":["Choose a different network name (e.g. append a suffix)","If the destination already exists, open it from the destination list instead of creating a new one","Refresh the page to clear stale form state and re-check"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// check before opening the form / before submit\n$exists = $server->swarmDockers()->where('network', $network)->exists();\nif ($exists) {\n    // prefill a unique name: $network .= '-'.Str::random(3);\n}","typeGuard":"function networkIsFreeOnServer($server, string $network): bool\n{\n    return $server->swarmDockers()->where('network', $network)->doesntExist();\n}","tryCatchPattern":null,"preventionTips":["Suggest unique network names in the UI (suffix with a short random id)","Show the server's existing networks in the form so duplicates are visible before submit","Remember the default `coolify` network is usually already registered during onboarding"],"tags":["livewire","docker-network","duplicate","destination","swarm"],"backgroundTag":"duplicate-network-name","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}