---
title: Deleting a project
slug: hosty/deleting-a-project
createdAt: 2026-11-08T11:27:49.007Z
---

Delete the environments of a project first, and only then remove the project from `main.tf`. Deleting an environment with Helm runs its cleanup: production gets a final backup, and the databases and search indexes of the environments are dropped. If OpenTofu removes the namespaces while environments are still in them, nothing of that runs, and their databases stay behind in Aurora.

Work in the Hosty container (`make cli`) with an MFA session (`hosty auth`) and the VPN connected.

## 1. Delete the development environments

List them:

```bash
helm ls --all -n <project>-development
```

`--all` also shows releases that failed or got stuck. Delete each of them. The name of a release is `<project>-<environment>`:

```bash
helm uninstall -n <project>-development <project>-<environment>
```

For example, `helm uninstall -n shop-development shop-stage`. This does the same as `hosty delete stage`, which the developers of the project can run themselves.

## 2. Delete production

Only admins can delete production. Hosty CLI refuses to do it, and an admission policy blocks everyone else.

```bash
helm uninstall -n <project>-production <project>-production
```

Before anything is removed, a job makes a final full backup of the database and the files of each application. Then the cleanup job drops the database. `helm uninstall` waits for both, so give it time on a large site.

Check that both namespaces have no releases left:

```bash
helm ls --all -n <project>-production
helm ls --all -n <project>-development
```

## 3. Remove the project from main.tf

Remove the project from `projects` in `terraform/main.tf`, then apply:

```bash
cd /src/terraform
tofu plan
tofu apply
```

OpenTofu deletes the namespaces, the IAM groups and roles of the project, its certificates and DNS records, the passwords of its database accounts, and its ECR repository with all its images.

## 4. Clean up what stays

Some things outlive the project, on purpose or because OpenTofu can't reach them:

- **Backups.** Database backups stay in `backups.database.<hosted zone>/<project>/` and expire after `database_backup_retention_days` of the hosting. Backups of files in `backups.files.<hosted zone>/<project>/` never expire. Delete them yourself once you're sure nobody needs them.
- **Database accounts.** On MySQL, the accounts `<project>_production` and `<project>_development` stay in the database. Drop them with the master user of the database, whose password is in Secrets Manager:

  ```sql
  DROP USER '<project>_production'@'%', '<project>_development'@'%';
  ```

  Hyphens in the name of the project are underscores in these names.
- **The CI user** of the project stays in `users`. Remove it as described in [Deleting a user](https://wiki.systemseed.com/hosty/deleting-a-user).
- **DNS records** of the custom domains, and their validation records, stay in the DNS of those domains, for example in Cloudflare.
