# Delete a load balancer

Delete a load balancer with its services, targets and rules, and release its addresses.

The instances that were targets keep running; only the forwarding stops.

**Warning:**
Deleting cannot be undone. An `lb11`, `lb21`, `lb31` or public `dedicated` load balancer's IPv4
and IPv6 addresses are released, so a DNS record that points at them stops reaching your
instances, and a new load balancer gets new addresses. An `application` load balancer's platform
name and the names of its `https` services stop being served; the fleet's shared addresses stay.

## Prerequisites

- Permission for `lb:DeleteLoadBalancer` on the load balancer.
- In the console, also `lb:DescribeLoadBalancers` on it; without it its page answers 404.
- A load balancer that is the endpoint of one of your databases, caches, brokers or MySQL clusters
  is deleted with that service, and one a Kubernetes Service of type LoadBalancer owns is deleted
  by deleting that Service. Neither can be deleted here: the console shows no **Danger zone** tab
  for the first, and a disabled button for the second.

## Delete it

**Console**
1. Open **Load balancers**, then open the load balancer.
2. Open the **Danger zone** tab. (The **Delete load balancer** item of the page's actions menu
   opens it too.)
3. Under **Delete this load balancer**, choose **Delete load balancer**.
4. Type the load balancer's name, then choose **Delete load balancer**.

The console returns to the list. Without the permission, the row says
"Your policies do not grant lb:DeleteLoadBalancer; ask an administrator." and the button is off.

**CLI**
```sh
dcloud lb load-balancers delete lb-id
```

**API**
```http
DELETE /lb/api/load-balancers/lb-id
```

**Terraform**
Remove the `dcloud_lb` resource from your configuration and apply, or run
`terraform destroy -target=dcloud_lb.web`.

## Result

The call answers once the load balancer is gone: `200` with its `id`. An `lb11`, `lb21` or
`lb31` is deleted at the provider first; a `dedicated` one releases its address first; an
`application` one leaves the fleet with its next configuration.

## When it is refused

- `409` for a load balancer another service owns; see Prerequisites.
- `502` when the provider refuses the delete. The load balancer is then in `error`, with the
  reason shown on its page; try again.
- `404` `Load balancer not found`.

## Related

- [Point a domain at a load balancer](point-a-domain.md)
- [Create a load balancer](create-a-load-balancer.md)
