How to Destroy Load Balancers

DigitalOcean Load Balancers are a fully-managed, highly available network load balancing service. Load balancers distribute traffic to groups of Droplets, which decouples the overall health of a backend service from the health of a single server to ensure that your services stay online.


You can destroy a load balancer if you no longer need it. This is a permanent, irreversible action.

Note
Destroying a load balancer does not destroy the Droplets that were associated with it. You can destroy these Droplets separately.

Delete a Load Balancer Using Automation

How to delete a load balancer using the DigitalOcean CLI

To delete a load balancer via the command-line, follow these steps:

  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token, and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

                  doctl auth init
                
  4. Finally, delete a load balancer with doctl compute load-balancer delete. The basic usage looks like this, but you'll want to read the usage docs for more details:

                  doctl compute load-balancer delete <id> [flags]
                

                  
                
How to delete a load balancer using the DigitalOcean API

To delete a load balancer using the DigitalOcean API, follow these steps:

  1. Create a personal access token, and save it for use with the API.

  2. Send a DELETE request to https://api.digitalocean.com/v2/load_balancers/{lb_id}

    cURL

    To delete a load balancer with cURL, call:

    
                    curl -X DELETE \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/load_balancers/4de7ac8b-495b-4884-9a69-1050c6793cd6"

    Go

    Go developers can use Godo, the official DigitalOcean V2 API client for Go. To delete a load balancer with Godo, use the following code:

    
                    import (
        "context"
        "os"
    
        "github.com/digitalocean/godo"
    )
    
    func main() {
        token := os.Getenv("DIGITALOCEAN_TOKEN")
    
        client := godo.NewFromToken(token)
        ctx := context.TODO()
    
        _, err := client.LoadBalancers.Delete(ctx, "4de7ac8b-495b-4884-9a69-1050c6793cd6")
    }

    Ruby

    Ruby developers can use DropletKit, the official DigitalOcean V2 API client for Ruby. To delete a load balancer with DropletKit, use the following code:

    
                    require 'droplet_kit'
    token = ENV['DIGITALOCEAN_TOKEN']
    client = DropletKit::Client.new(access_token: token)
    
    client.load_balancers.delete(id: '4de7ac8b-495b-4884-9a69-1050c6793cd6')

    Python

    
                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    resp = client.load_balancers.delete(lb_id="afda3ad")

Destroy a Load Balancer Using the Control Panel

From the control panel, click Networking, then click Load Balancers to go to the load balancer overview page. Click on the name of the load balancer you want to destroy to go to its index page, then click Settings.

Load Balancers settings page

In the Destroy section, click the Destroy button. In the Destroy Load Balancer window that opens, click Confirm to permanently destroy the load balancer.