Problem
"I’m trying to delete a flow and a deployment.
When I try to delete via the UI I get Failed to delete deployments
and if I delete with API, I get a TimeoutError."
Explanation
You likely have a large number of completed flow runs that Prefect is trying to delete as part of the request to delete a deployment. Having flow runs from deployments without corresponding deployment (deleted deployment) would be confusing. Hence Prefect attempts to first delete all flow runs related to that deployment before deleting the deployment.
Solution
Try deleting those flow runs yourself first (potentially step by step, i.e. not all at once - potentially as paginated requests, or selecting only a couple of runs from the UI) and then once all those runs are deleted, the delete-deployment request should no longer time out.