coollabsio/coolify · warning · Exception

Environment with the same name already exists.

Error message

Environment with the same name already exists.

What it means

When cloning into the same project as a new environment, Coolify checks the project's environments for the requested name and refuses duplicates - environment names are unique within a project.

Source

Thrown at app/Livewire/Project/CloneMe.php:125

                if ($foundProject) {
                    throw new \Exception('Project with the same name already exists.');
                }
                $project = Project::create([
                    'name' => $this->newName,
                    'team_id' => currentTeam()->id,
                    'description' => $this->project->description.' (clone)',
                ]);
                if ($this->environment->name !== 'production') {
                    $project->environments()->create([
                        'name' => $this->environment->name,
                        'uuid' => new_public_id(),
                    ]);
                }
                $environment = $project->environments->where('name', $this->environment->name)->first();
            } else {
                $foundEnv = $this->project->environments()->where('name', $this->newName)->first();
                if ($foundEnv) {
                    throw new \Exception('Environment with the same name already exists.');
                }
                $project = $this->project;
                $environment = $this->project->environments()->create([
                    'name' => $this->newName,
                    'uuid' => new_public_id(),
                ]);
            }
            $applications = $this->environment->applications;
            $databases = $this->environment->databases();
            $services = $this->environment->services;
            foreach ($applications as $application) {
                clone_application($application, $selectedDestination, [
                    'environment_id' => $environment->id,
                ], $this->cloneVolumeData);
            }

            foreach ($databases as $database) {
                $uuid = new_public_id();

View on GitHub (pinned to 70b9acc424)

Solutions

  1. Pick a fresh environment name for the clone (e.g. staging-2, review-copy)
  2. Rename or delete the existing environment first if the clone is meant to replace it
Defensive patterns

Strategy: validation

Validate before calling

// inline check before submit
if ($project->environments()->where('name', $newName)->exists()) {
    // suggest $newName.'-'.Str::random(3)
}

Type guard

function environmentNameIsFree($project, string $name): bool
{
    return $project->environments()->where('name', $name)->doesntExist();
}

Prevention

When it happens

Trigger: Cloning an environment using a name that already exists in the target project, e.g. cloning 'production' into a project that already has a 'production' environment.

Common situations: Repeated clones colliding (staging-1, staging-2...); cloning an environment back into its own project with the same name.

Related errors


AI-assisted analysis of coollabsio/coolify@70b9acc424 (2026-08-17). Data as JSON: /api/errors/f69b5b3771ac5900. Report an issue: GitHub.