{"record":{"id":"c4a52b4928eb459e","repo":"coollabsio/coolify","slug":"the-server-is-unavailable","errorCode":null,"errorMessage":"The server is unavailable.","messagePattern":"The server is unavailable\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"app/Livewire/Project/Shared/Storages/VolumeBackups.php","lineNumber":300,"sourceCode":"\n        $execution = $this->backup?->executions()->whereKey($executionId)->first();\n        if (! $execution) {\n            $this->dispatch('error', 'Backup execution not found.');\n\n            return false;\n        }\n\n        if ($execution->status === 'running' || $execution->stop_recovery_pending || $execution->s3_cleanup_pending) {\n            $this->dispatch('error', 'Wait for the backup and recovery operations to finish before deleting it.');\n\n            return false;\n        }\n\n        try {\n            $server = $this->backup->server();\n            if (! $execution->local_storage_deleted && filled($execution->filename)) {\n                if (! $server) {\n                    throw new \\RuntimeException('The server is unavailable.');\n                }\n\n                deleteBackupsLocally($execution->filename, $server, throwError: true);\n            }\n\n            if ($this->delete_backup_s3 && $execution->s3_uploaded && ! $execution->s3_storage_deleted) {\n                if (! $execution->s3) {\n                    throw new \\RuntimeException('The S3 storage is unavailable.');\n                }\n\n                deleteBackupsS3($execution->filename, $execution->s3);\n            }\n\n            $execution->delete();\n            $this->delete_backup_s3 = false;\n            $this->dispatch('success', 'Backup deleted.');\n\n            return true;","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/coollabsio/coolify/blob/70b9acc42467278373e00de77abb40684e25b395/app/Livewire/Project/Shared/Storages/VolumeBackups.php#L282-L318","documentation":"While deleting a backup execution on the volume-backups screen, local files still need removal (local_storage_deleted is false and filename is filled) but $this->backup->server() returned null - the backup's server relation cannot be resolved any more. Without a Server model, deleteBackupsLocally() has nowhere to SSH, so the deletion aborts before dropping the execution row.","triggerScenarios":"The server that hosted the backup files was deleted from Coolify after backups ran; the backup's storage type has a null server() relation; a dangling server_id on the storage after a failed transfer or manual DB edit.","commonSituations":"Decommissioning a server and then cleaning up its old backup executions; team merges/migrations that leave orphaned storages; executions whose local files were already lost with the host.","solutions":["Re-add/restore the server so backup->server() resolves, then retry the delete","If the files are already gone, mark the execution as locally cleaned (execution->local_storage_deleted = true; execution->save()) and delete again","Otherwise SSH to the old host, remove the files under the backup path manually, then flip the flag","Inspect the backup's server() relation and server_id column to confirm which linkage is broken"],"exampleFix":"// before\n$server = $this->backup->server();\ndeleteBackupsLocally($execution->filename, $server, throwError: true);\n\n// after\n$server = $this->backup->server();\nif (! $server) {\n    $execution->local_storage_deleted = true; // files unreachable\n    $execution->save();\n} else {\n    deleteBackupsLocally($execution->filename, $server, throwError: true);\n}","handlingStrategy":"validation","validationCode":"if (! $execution->local_storage_deleted && filled($execution->filename) && ! $this->backup->server()) {\n    // server unreachable: either block deletion or mark local files deleted deliberately\n    return 'Cannot delete local backup files: server is unavailable.';\n}","typeGuard":"/** @param mixed $backup */\nfunction backupHasLiveServer($backup): bool\n{\n    $server = $backup?->server();\n    return $server instanceof \\App\\Models\\Server;\n}","tryCatchPattern":"Catch Throwable around the delete flow, dispatch('error', 'Failed to delete backup: '.$e->getMessage()), and keep the execution row (do not partially delete state) - the component already leaves deletion to the tail of the try block.","preventionTips":["Delete backup executions before removing the server that hosts them","When decommissioning a server, export/clear its backups first","Flag local_storage_deleted = true when files are known-lost instead of fighting the guard"],"tags":["backup","server","deletion","volume"],"backgroundTag":"missing-related-resource","analyzedSha":"70b9acc42467278373e00de77abb40684e25b395","analyzedAt":"2026-08-17T01:41:01.313Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}