coollabsio/coolify · error · RuntimeException
Destination does not belong to the current team.
Error message
Destination does not belong to the current team.
What it means
clone_application() in bootstrap/helpers/applications.php clones an application into a destination (a StandaloneDocker/SwarmDocker network). Before copying anything it resolves $destination->server and verifies the server's team_id equals currentTeam()->id; on mismatch it throws RuntimeException 'Destination does not belong to the current team.'. This is a multi-tenancy guard: a destination uuid alone is never sufficient authorization.
Source
Thrown at bootstrap/helpers/applications.php:198
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
]);
ApplicationDeploymentJob::dispatch(
application_deployment_queue_id: $next->id,
);
}
}
}
}
}
function clone_application(Application $source, $destination, array $overrides = [], bool $cloneVolumeData = false): Application
{
$uuid = $overrides['uuid'] ?? new_public_id();
$server = $destination->server;
if ($server->team_id !== currentTeam()->id) {
throw new RuntimeException('Destination does not belong to the current team.');
}
// Prepare name and URL
$name = $overrides['name'] ?? 'clone-of-'.str($source->name)->limit(20).'-'.$uuid;
$applicationSettings = $source->settings;
$url = $overrides['fqdn'] ?? $source->fqdn;
if ($server->proxyType() !== 'NONE' && $applicationSettings->is_container_label_readonly_enabled === true) {
$url = generateUrl(server: $server, random: $uuid);
}
// Clone the application
$newApplication = $source->replicate([
'id',
'created_at',
'updated_at',
'additional_servers_count',
'additional_networks_count',View on GitHub (pinned to 70b9acc424)
Solutions
- Switch your active team to the team that owns the destination server, then retry the clone.
- Or pick a destination (docker network) that belongs to your current team.
- Verify before calling: compare $destination->server->team_id against currentTeam()->id.
- If you own both teams, move or recreate the destination under the correct team instead of bypassing the check.
Example fix
// before
$destination = StandaloneDocker::whereUuid($uuid)->firstOrFail();
$clone = clone_application($application, $destination); // RuntimeException
// after: scope the lookup to the current team's servers
$destination = StandaloneDocker::whereUuid($uuid)
->whereHas('server', fn ($q) => $q->where('team_id', currentTeam()->id))
->firstOrFail();
$clone = clone_application($application, $destination); Defensive patterns
Strategy: validation
Validate before calling
use App\Models\StandaloneDocker;
$destination = StandaloneDocker::whereUuid($uuid)
->whereHas('server', fn ($q) => $q->where('team_id', currentTeam()->id))
->first();
if (! $destination) {
abort(403, 'Pick a destination owned by your current team.');
} Type guard
function destinationBelongsToCurrentTeam(StandaloneDocker|SwarmDocker $destination): bool
{
return (int) $destination->server->team_id === (int) currentTeam()->id;
} Try / catch
try {
$clone = clone_application($application, $destination);
} catch (\RuntimeException $e) {
if (str_contains($e->getMessage(), 'Destination does not belong')) {
// surface a friendly 'switch team' prompt
}
throw $e;
} Prevention
- Scope all destination pickers/queries by server.team_id = current team
- Re-derive currentTeam() server-side at request start; never trust client-stored team ids
- Treat uuids as opaque identifiers, never as authorization
When it happens
Trigger: Calling clone_application() with a destination whose server belongs to another team (e.g. a uuid pasted from another team's server); the active team being switched in another browser tab so currentTeam()->id no longer matches the destination used by the UI; API callers reusing one team's destination uuid while authenticated against a different team.
Common situations: Multi-team Coolify instances where a user belongs to two teams and the destination picker shows stale data after switching teams; automation that hardcodes a destination uuid regardless of the authenticated team.
Related errors
- Destination not found.
- Recipient is not part of the team
- Server not found.
- Network already added to this server.
- Project with the same name already exists.
AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17).
Data as JSON: /api/errors/f01a02793a22ab3f.
Report an issue: GitHub.